Temporarily removing the dev warnings. I've moved these to be errors in the build side. In a follow up PR I will use prerendering during dev to trigger these errors and report them as dev errors as well. This also updates how we track sync dynamic errors. The main goal is to have a stack trace of the sync function and separately report all the component stacks that might contain this function call. It's not fool-proof b/c the sync api may be called in a way that is not observed by SSR. The whole debugging story here will improve dramatically with owner stacks but that is currently experimental only in React. The plan for future updates is to add a prospective render for SSR so we can flush out module scope issues like calling Math.random while lazy initializing a module. This is asserted for RSC in this change (see new tests) but won't wouldn't pass for SSR b/c we only do single pass prerendering at the moment. After that I will add in the prerender-while-render in dev and utilize the prerender errors to power dev as well.
2.7 KiB
title
| title |
|---|
| Cannot access Request information synchronously with Page or Layout or Route `params` or Page `searchParams` |
Why This Error Occurred
In Next.js 15 params passed into Page and Layout components and searchParams passed into Page components are now Promises.
To support migrating to the async params and searchParams Next.js 15 still supports accessing param and searchParam values directly on the Promise object. However when dynamicIO is enabled it is an error to do so.
Possible Ways to Fix It
If you haven't already followed the Next.js 15 upgrade guide which includes running a codemod to auto-convert to the necessary async form of params and searchParams start there.
If you have already run the codemod on your project look for instances of the string @next-codemod-error to see where the codemod was unable to convert to the async form. You will have to refactor your code manually here to make it compatible with the new result type.
Before:
// This component ends up being the Page component even though it is defined outside of
// page.js due to how it is reexported in page.js
export default function ComponentThatWillBeExportedAsPage({ params, searchParams }) {
const { slug } = params;
const { page } = searchParams
return <RenderList slug={slug} page={page}>
}
// the codemod cannot find the actual Page component so the Page may still have remaining
// synchronous access to params and searchParams
// @next-codemod-error
export * from '.../some-file'
After:
// This component ends up being the Page component even though it is defined outside of
// page.js due to how it is reexported in page.js
export default async function ComponentThatWillBeExportedAsPage({ params, searchParams }) {
const { slug } = await params;
const { page } = await searchParams
return <RenderList slug={slug} page={page}>
}
export * from '.../some-file'
It is unexpected that you would run the codemod and not successfully convert all instances of params and searchParams to async or have a marker string to help you locate unconverted cases. If you do find yourself in this situation please report this to Next.js on Github.