You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: next/root-params erroring when rerendering after action (vercel#82326)
When implementing the check that disallows using `next/root-params` in
server actions, i forgot that when a page is rerendered after an action,
the render is still wrapped with an `actionAsyncStorage` with
`actionStore.isAction === true`. The fix is to also check that we're in
the `'action'` phase, i.e. we haven't switched to rendering yet.
Closesvercel#82302
Copy file name to clipboardExpand all lines: packages/next/errors.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -771,5 +771,6 @@
771
771
"770": "createParamsFromClient should not be called in a runtime prerender.",
772
772
"771": "\\`%s\\` was called during a runtime prerender. Next.js should be preventing %s from being included in server components statically, but did not in this case.",
773
773
"772": "FetchStrategy.PPRRuntime should never be used when `experimental.clientSegmentCache` is disabled",
774
-
"773": "Missing workStore in createPrerenderParamsForClientSegment"
774
+
"773": "Missing workStore in createPrerenderParamsForClientSegment",
775
+
"774": "Route %s used %s outside of a Server Component. This is not allowed."
"`import('next/root-params').lang()` was used inside a Server Action. This is not supported. Functions from 'next/root-params' can only be called in the context of a route."
114
131
)
115
132
}
116
133
})
117
134
135
+
it('should not error when rerendering the page after a server action',async()=>{
// We're using lang() outside of an action, so we should see no errors
159
+
expect(response.status()).toBe(200)
160
+
if(!isNextDeploy){
161
+
expect(getCliOutput()).not.toInclude(
162
+
"`import('next/root-params').lang()` was used inside a Server Action. This is not supported. Functions from 'next/root-params' can only be called in the context of a route."
163
+
)
164
+
}
165
+
166
+
awaitretry(async()=>{
167
+
// The page should've been rerendered because of the cookie update
"Route /[lang]/[locale]/route-handler used `import('next/root-params').lang()` inside a Route Handler. Support for this API in Route Handlers is planned for a future version of Next.js."
0 commit comments