perf(app-router): defer post-middleware cookie materialisation#2490
Draft
NathanDrake2406 wants to merge 3 commits into
Draft
perf(app-router): defer post-middleware cookie materialisation#2490NathanDrake2406 wants to merge 3 commits into
NathanDrake2406 wants to merge 3 commits into
Conversation
Post-middleware request context eagerly materialised cookies and query state even when config has/missing predicates did not need them. On Workers this added per-request cookie parsing on route and document paths with no cookie conditions. Track whether each config rule can read cookies or query params, expose lazy cookies/query to rewrite matching only when needed, and pre-materialise cookies before progressive action dispatch when a late rewrite predicate could otherwise observe action-time cookie mutations. Adds regression coverage for middleware-mutated cookie rewrites, lazy post-middleware cookie materialisation, late progressive-action cookie snapshots, and condition access scanning.
commit: |
Contributor
Performance benchmarksCompared 1 improved · 0 regressed · 5 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
config-matchers.ts,app-post-middleware-context.ts,app-rsc-handler.tsWhy
hasandmissingpredicates are the only config rewrite checks that need request cookies or query params. The post-middleware request context was materialising cookies and query state even when the matching rule could only inspect path/header/host state. On Workers this showed up as a fixed per-request cookie parse on ordinary route and document requests.What changed
Object.fromEntries(ctx.cookies)andurl.searchParamswere built eagerly.Evidence
Local Worker evidence run from
tests/fixtures/app-basic,workerdvia the existing app-router Worker harness, 500 measured requests, 50 warmup, concurrency 4. Latency is local and noisy, so the deterministic counter is the important signal./api/hello/aboutFinal candidate counter run also kept cookie-gated rewrite scenarios at
1.00request cookie parse/request and route/document at0.00.Validation
vp check tests/app-post-middleware-context.test.ts tests/app-rsc-handler.test.ts tests/shims.test.ts packages/vinext/src/config/config-matchers.ts packages/vinext/src/server/app-post-middleware-context.ts packages/vinext/src/server/app-rsc-handler.tsvp test run tests/app-post-middleware-context.test.ts tests/app-rsc-handler.test.ts tests/shims.test.ts -t "cookie-gated rewrite|post-middleware cookie snapshot|does not materialise middleware cookies|reports cookie and query condition access separately"vp test run tests/app-post-middleware-context.test.ts tests/app-rsc-handler.test.tsvp run vinext#buildVINEXT_APP_ROUTER_WORKER_EVIDENCE_REQUESTS=500,WARMUP=50,CONCURRENCY=4