Closed
Description
Link to reproduction
No response
Environment Info
Binaries:
Node: 20.16.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
payload: 3.0.0-beta.109
next: 15.0.0-canary.172
@payloadcms/db-postgres: 3.0.0-beta.109
@payloadcms/email-nodemailer: 3.0.0-beta.109
@payloadcms/graphql: 3.0.0-beta.109
@payloadcms/next/utilities: 3.0.0-beta.109
@payloadcms/plugin-cloud: 3.0.0-beta.109
@payloadcms/plugin-nested-docs: 3.0.0-beta.109
@payloadcms/plugin-redirects: 3.0.0-beta.109
@payloadcms/plugin-seo: 3.0.0-beta.109
@payloadcms/richtext-lexical: 3.0.0-beta.109
@payloadcms/translations: 3.0.0-beta.109
@payloadcms/ui/shared: 3.0.0-beta.109
react: 19.0.0-rc-3edc000d-20240926
react-dom: 19.0.0-rc-3edc000d-20240926
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Available memory (MB): 65459
Available CPU cores: 24
Done in 3.03s.
Describe the Bug
As of Next.js v15.0.0-canary.171, the following change was introduced:
vercel/next.js#68812
You can read more about the change here:
vercel/next.js#68812
In short, it makes params / headers return promises so you have to await them. Its meant to also allow the previous approach for backwards compatability temporarily. However, it seems like this is not working as intended and it breaking next build
(production builds).
The errors stem from the api/payload
folder.
Example build error from yarn build
:
Linting and checking validity of types ...Failed to compile.
.next/types/app/(payload)/admin/[[...segments]]/page.ts:30:29
Type error: Type 'Args' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ segments: string[]; }' is missing the following properties from type 'Promise<SegmentParams>': then, catch, finally, [Symbol.toStringTag]
28 |
29 | // Check the prop type of the entry function
> 30 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
| ^
31 |
32 | // Check the arguments and return type of the generateMetadata function
33 | if ('generateMetadata' in entry) {
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Example console errors during yarn dev
:
In route /api/[...slug] a param property was accessed directly with `params.slug`. `params` is now a Promise and should be awaited before accessing properties of
the underlying params object. In this version of Next.js direct access to param properties is still supported to facilitate migration but in a future version you will be required to await `params`. If this use is inside an async function await it. If this use is inside a synchronous function then convert the function to async or await it from outside this function and pass the result in.
Reproduction Steps
- Use any Payload project using
payload
3.0.0-beta.109
andnextjs
15.0.0-canary.171
. yarn dev
- Load a
/api/
route. - Observe errors in console.
yarn build
- Observe type errors that fail the build.
Adapters and Plugins
No response