fix(pages): re-enter filesystem routes after rewrites - #2041
Conversation
commit: |
|
|
/bigbonk review for issues |
|
@james-elicx Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
|
/bigbonk review for issues |
|
|
Review posted to PR #2041. SummaryI reviewed the post-rewrite filesystem re-entry change in PR #2041 across all four request handlers (pipeline, Node prod, Worker, Vite dev), verified dev/prod/worker parity, and ran the targeted suites. Verification:
Findings (1 concrete, 2 notes):
The core fix is correct and well-tested; the upstream-test porting and the |
|
/bigbonk review for issues |
|
|
Review posted to PR #2041. SummaryI independently re-reviewed PR #2041's post-rewrite filesystem re-entry change across the pipeline and all three runtime adapters (Node prod, Worker, Vite dev), plus the dev dot-path preflight. Verification:
Findings:
The core fix is correct, matches Next.js routing order, and is well-tested. |
652943a to
7d22155
Compare
locale: falsepublic rewrite parity investigationOutcome
Confirmed and fixed a real vinext parity gap from Actions run
27514800656.Next.js re-enters filesystem routing after config rewrites. Vinext applied the
rewrite destination to page/API dispatch, but only probed public and built
static files before rewrites. Consequently, a
locale: falserewrite from alocalized source to
/file.txtor/_next/static/...returned 404.Baseline
a3d2f921520ff140a826224616df5e0db4ed0186v16.2.6ee6e79b1792a4d401ddf2480f40a83549fe8e722/tmp/vinext-locale-false-public.MmAbBc/vinextcodex/fix-locale-false-public-rewritesExact upstream assertions
Suite:
test/e2e/i18n-ignore-rewrite-source-locale/rewrites.test.tsThe source config uses a
beforeFilesrewrite:The deploy run
27514800656failed the public-file assertion for/,/nl,and
/sv, returning Next 404 HTML instead ofhello from file.txt. The suite'sAPI rewrite was the control and showed that rewrite matching itself worked.
Local reproduction on unmodified main
Added a vinext Pages fixture with locales
en,sv, andnl, a public textfile, a page, an API route, and rewrite destinations for public, built-static,
page, and API routes.
Targeted command:
vp test run tests/pages-i18n-public-rewrite.test.tsBaseline result: 5/5 failed. Both default-locale (
/en) and non-default-locale(
/sv) public rewrites returned 404 in development and production. The API andpage controls passed, while the rewritten built-static destination also
returned 404.
Fix
filesystem-route callback.
beforeFiles,afterFiles, andfallbackrewrites, matching Next.js routing order.afterFilesandfallbackrewrites.range, MIME, ETag, and conditional-request behavior.
env.ASSETS.fetch, only forrewritten GET/HEAD non-API destinations.
The fix is not specific to locale parsing.
locale: falsematching alreadyproduced the correct destination; the missing behavior was post-rewrite
filesystem re-entry.
Independent review follow-up: dev dot-path preflight
Independent review found a separate dev-only gap in the early static-asset
preflight. For file-looking paths such as
/download.txt, dev decided whetherto enter the Pages pipeline by fully evaluating rewrite
has/missingconditions against the original request. That skipped middleware entirely when
middleware was responsible for adding the header that enabled the rewrite.
The preflight now checks only whether a rewrite's source pattern can match the
pathname. Request-dependent conditions remain deferred to the Pages pipeline,
after middleware request-header overrides have been applied. Paths that do not
match any rewrite source still bypass Pages handling, so unrelated static
assets continue through Vite's normal filesystem middleware.
Focused dev coverage verifies:
/download.txt?rewritereaches middleware, receives an injected requestheader, and rewrites to a Pages route.
/download.txtremains unmatched when middleware does not inject the header.Node production and Worker routing do not have the dev-only file-extension
preflight. Both already enter
runPagesRequest, run middleware, apply requestheader overrides, and evaluate config rewrites using the post-middleware
request context, so no runtime changes were required there.
Targeted validation
vp test run \ tests/pages-i18n-public-rewrite.test.ts \ tests/pages-request-pipeline.test.ts \ tests/deploy.test.tsResult: 349 tests passed.
Coverage includes default/non-default locales, dev/prod public files,
built-static assets, API/page controls,
beforeFiles/afterFiles/fallbackordering, Worker asset fetch generation, HEAD/range/ETag behavior, and misses.
Result: formatting, lint, and type checks passed.
git diff --checkpassed.Independent review follow-up validation:
Result: 3 focused integration tests passed; scoped formatting, lint, and type
checks passed;
git diff --checkpassed. The upstream deploy suite was notrerun for this dev-only follow-up.
Exact pinned Next.js deploy validation
NEXTJS_PREPARE=0 \ NEXT_TEST_CONCURRENCY=1 \ vp env exec --node 24 \ ./scripts/run-nextjs-deploy-suite.sh \ /Users/jamesanderson/Developer/vinext/.nextjs-ref \ --retries 0 -c 1 --debug \ test/e2e/i18n-ignore-rewrite-source-locale/rewrites.test.tsThe custom deployment succeeded at a local URL and reached assertions.
Result: 8/8 passed:
/en,/sv,/nl/en,/sv,/nlScope
No
cacheComponents,use cache, PPR shell, or resume code was changed. Nolockfile change was made. The branch was not pushed and no PR was opened.