Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js API not supported in Edge Runtime warnings when using basic Next.js middleware #6970

Closed
riley-pearce-airteam opened this issue Jun 28, 2024 · 3 comments
Labels

Comments

@riley-pearce-airteam
Copy link

Link to reproduction

https://github.com/riley-pearce-airteam/payload-middleware-issue

Payload Version

3.0.0-beta.55

Node Version

20.15.0

Next.js Version

15.0.0-rc.0

Describe the Bug

When a simple Next.js middleware file is present, warnings are present in the console while running pnpm build.

./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/cjs/react.react-server.production.js
A Node.js API is used (process.emit at line: 289) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/cjs/react.react-server.production.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/react.react-server.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/app-render/dynamic-rendering.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/after/after.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/after/index.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/web/exports/index.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/api/server.js

./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/cjs/react.react-server.production.js
A Node.js API is used (process.emit at line: 291) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/cjs/react.react-server.production.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/compiled/react/react.react-server.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/app-render/dynamic-rendering.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/after/after.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/after/index.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/server/web/exports/index.js
./node_modules/.pnpm/[email protected][email protected][email protected]__h5dcexdmtufgo4odrzqiwpy5oq/node_modules/next/dist/esm/api/server.js

Reproduction Steps

  • Create a fresh repo using blank 3.0 template.
  • Add a basic middleware.ts file.
  • Run pnpm build.
  • Warnings will show.

Adapters and Plugins

No response

@riley-pearce-airteam riley-pearce-airteam added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jun 28, 2024
@JarrodMFlesch
Copy link
Contributor

@riley-pearce-airteam this is not specific to Payload, this happens in a new blank NextJS project after adding middleware.

You can test this out by running pnpm create-next-app@rc --empty and then adding your middleware file the src directory. Be sure to remove .next folder before re-building to see the results.

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jul 8, 2024
@riley-pearce-airteam
Copy link
Author

Good catch @JarrodMFlesch, thanks for that. I will take a look over at the Next.js issues and see if the issue has been raised before.

Copy link

github-actions bot commented Sep 7, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants