-
Notifications
You must be signed in to change notification settings - Fork 28.3k
When external library polyfills it breaks Next.js #57242
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
Comments
Is this caused because Node's Fetch native API? So, rather, other libraries should check if native Node Fetch API is available, and skip doing polyfills? |
Yeah, I believe so. It's technically on other libraries to check and not do polyfills. However Next.js does the following in some cases:
Where it checks if the response is the same one it got initially made. If a library polyfills this will not be correct. Not everyone is ahead of the curve like Next.js, and some are still polyfilling (They shouldn't be), but mostly I think at the very least some documentation around this gotcha would be nice. Because this behavior which other libraries may not be aware of can cause some really unexpected behavior in Next.js. Took us a while to track down this bug, and I'd love it if others didn't have to experience it, or at the very least maybe they could figure out what was going on faster. |
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. |
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding! |
Link to the code that reproduces this issue
https://github.com/luthfib/auth0-nextjs-repro/tree/fetch-issue
To Reproduce
Current vs. Expected behavior
This bug is linked to #56969, however I was able to fix it by doing the following:
https://github.com/luthfib/auth0-nextjs-repro/blob/fetch-issue/app/api/auth/%5Bauth0%5D/route.ts
I believe Next.js crashed before I included the following line because of this line the Next.js code...
next.js/packages/next/src/server/future/route-modules/app-route/module.ts
Line 413 in 6ed4fdd
I think either Next.js needs to warn in the documentation that any library that polyfills fetch will break Next.js or the error if the library polyfills should be more clear. The library that polyfills in question is the following: https://github.com/Vermonster/fhir-kit-client/blob/3b36f30f29f5bbeac356feed0db6ce3be3eeb711/lib/http-client.js#L3.
Spent quite a bit of time with a few engineers to figure out what was causing the issue, so some kind of warning would be helpful.
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000 Binaries: Node: 18.11.0 npm: 8.19.2 Yarn: N/A pnpm: 8.9.2 Relevant Packages: next: 13.5.6 eslint-config-next: 13.5.5 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
No response
The text was updated successfully, but these errors were encountered: