Flag dev static indicator as Dynamic when route reads searchParams#92605
Draft
yogeshwaran-c wants to merge 1 commit intovercel:canaryfrom
Draft
Flag dev static indicator as Dynamic when route reads searchParams#92605yogeshwaran-c wants to merge 1 commit intovercel:canaryfrom
yogeshwaran-c wants to merge 1 commit intovercel:canaryfrom
Conversation
In app router dev, awaiting `searchParams` in a page did not update `requestStore.usedDynamic`, so the dev static indicator reported the route as Static even though it would render dynamically at build time. Hook property access on the resolved searchParams proxy (and the sync misuse path on the promise proxy) to flip `usedDynamic` via `trackDynamicDataInDynamicRender`, matching how `cookies()` and `headers()` already track dynamic usage. Framework `.then` probes on the promise proxy are left untouched to avoid over-reporting. Fixes vercel#72133
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
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.
What?
Fixes the dev static indicator reporting a route as Static when the page reads
searchParams. It now correctly reports Dynamic, matching how the same route is treated at build time.Why?
searchParamsis a dynamic API in the app router — awaiting it (or accessing a property on the resolved value) forces the route to render dynamically. However,createRenderSearchParamsin dev did not updaterequestStore.usedDynamic, so the dev indicator — which derives its state fromisStatic = !usedDynamic && !forceDynamicinapp-render.tsx— showed Static even thoughnext buildcorrectly marked the same route dynamic. This caused confusing dev/build drift for users ofsearchParams.How?
cookies()andheaders()already flipusedDynamicviatrackDynamicDataInDynamicRender()at their call site.searchParamscan't do the same at its creation site becausecreateServerSearchParamsForServerPageruns for every server component page, whether the page uses searchParams or not — tracking there would over-report every page as dynamic.Instead, the dev proxy traps in
makeUntrackedSearchParamsWithDevWarningsnow calltrackDynamicDataInDynamicRender(requestStore):instrumentSearchParamsObjectWithDevWarnings): anyget/has/ownKeysaccess that occurs afterpromiseInitialized.current === true. This is the path that fires only when user code doesconst sp = await searchParams; sp.a(or similar), so framework probes are excluded.instrumentSearchParamsPromiseWithDevWarnings): sync misuse paths (property /in/Object.keyson the promise itself without awaiting). Left the.thentrap alone to avoid counting framework internals as dynamic access.trackDynamicDataInDynamicRenderis already a no-op in production, so the change is dev-indicator-only at runtime.Test plan
Added a new
search-params/page.tsxfixture plus a test case totest/development/app-dir/dev-indicator/route-type.test.tsthat reproduces the original bug (reported as Static on canary without the fix). The existing static / force-dynamic / headers cases in the same suite still pass, confirming no over-reporting.Also ran the adjacent suites that exercise searchParams behavior to catch regressions:
test/development/app-dir/async-request-warnings/async-request-warnings.test.ts— 7/7 pass (includes sync searchParams access warning).test/e2e/app-dir/searchparams-static-bailout/searchparams-static-bailout.test.ts— 5/5 pass (covers both server and client component searchParams).Fixes #72133