Repository navigation
fix(core): revalidate ISR cache for notFound PDP/PLP paths - #3436
Conversation
Prevent permanent 404 caching when Search/stock gaps cause the first generation (often via prefetch) to miss a product that later becomes available.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughNot-found responses in both slug page handlers now use ChangesNot-found response revalidation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/diagnostics
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
renatomaurovtex
left a comment
There was a problem hiding this comment.
Reviewed the diff plus the surrounding getStaticProps flows in both pages. This is the right minimal fix: the Pages Router notFound branch had no revalidate, so a transient Search/stock miss froze the path on 404 until a rebuild. The change is consistent with the existing 5-minute window already used for the enableRedirects branch, and experimental is already accessed unconditionally in both files, so there's no new undefined risk.
packages/core/src/pages/[slug]/p.tsx
💬 404 window inherits the store's success-page revalidate — a store that sets experimental.revalidate high (e.g. hours) for product pages will now also freeze transient 404s for that long, which works against the goal of this fix (recover quickly from a transient miss). Intentional trade-off, or would you cap it?
- revalidate:
- (storeConfig as StoreConfig).experimental.revalidate ?? 60 * 5, // 5 minutes
+ revalidate: Math.min(
+ (storeConfig as StoreConfig).experimental.revalidate ?? 60 * 5,
+ 60 * 5
+ ), // never freeze a 404 for longer than 5 minutesNot blocking — matching the success-page window is also a defensible choice; just confirm it's deliberate.
packages/core/src/pages/[...slug].tsx
💬 PLP/landing hardcodes 60 * 5 while PDP honors experimental.revalidate — consistent with the fact that the PLP success path doesn't use the config either, and matches the PR description. Just confirming the asymmetry is intentional.
Verdict: Approved
Blocking (🔴/🟠):
- None.
Non-blocking (🟡/💬):
- 💬 Consider capping the PDP 404 window at 5 minutes when
experimental.revalidateis large. - 💬 PDP/PLP asymmetry — confirm intentional.
Checks to confirm before merge: build · UI Tests (pending at review time)
Keep the successful PDP ISR window independent so a long revalidate does not freeze transient 404s.
|
@renatomaurovtex sobre os pontos do review: em vez de capar o 404 no |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/pages/`[...slug].tsx:
- Around line 218-227: Update the fetchServerManyProducts flow in getStaticProps
to account for its possible undefined result before destructuring. Prefer
propagating the original request error from fetchServerManyProducts, or return
and handle an explicit typed fallback, so failed requests never trigger
“undefined is not iterable” and the original failure remains visible.
- Around line 218-227: Move fetchServerManyProducts back into the successful PLP
Promise.all flow in the page loader, starting it alongside the collection, CMS
content, and global-section requests rather than after they resolve. Preserve
the existing notFound and error checks before awaiting successful results, and
keep the current product query arguments unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 51beabcf-a134-4433-9101-fbf09e140844
📒 Files selected for processing (3)
packages/core/discovery.config.default.jspackages/core/src/pages/[...slug].tsxpackages/core/src/pages/[slug]/p.tsx
|

0 New Issues
0 Fixed Issues
0 Accepted Issues
What's the purpose of this pull request?
PDPs (and PLP/slug pages) that first resolve as
notFoundwere cached forever by Next ISR, so a transient Search/stock miss — often triggered by prefetch — left the path stuck on 404 until a full rebuild. Tracked in SO-650 / SFS-3089How it works?
When
getStaticPropsreturnsnotFound: true, it now also setsrevalidate(storeexperimental.revalidateon PDP, otherwise 5 minutes — same window as redirects). Next can regenerate the path after the window instead of freezing the 404.packages/core/src/pages/[slug]/p.tsxpackages/core/src/pages/[...slug].tsxUpgrading to FastStore v4 / Next 16 alone does not fix this; the Pages Router
notFoundbranch had norevalidatebefore or after that migration.How to test it?
fallback: 'blocking'), confirm response includes a finite revalidation window (not permanent)enableRedirectsstill revalidate at 5 minutesStarters Deploy Preview
Sandbox PR on
faststoreqa.storewill follow once CodeSandbox CI publishes this commit.References
Checklist
PR Title and Commit Messages
fix)PR Description
bugDependencies
Documentation
Made with Cursor
Summary by CodeRabbit
Summary by CodeRabbit