next.js
ca0957df - Prevent unhandled rejection filter from being bundled into the server runtime (#90205)

Commit
59 days ago
Prevent unhandled rejection filter from being bundled into the server runtime (#90205) The unhandled-rejection module was being bundled into server.runtime.prod.js AND loaded as a standalone file, causing installUnhandledRejectionFilter() to run twice. Each instance captured the other's handler as an underlying listener, creating mutual recursion that overflowed the stack on any unhandled rejection. Fix: Rename to .external.tsx so the webpack config externalizes it from the server runtime bundle. It is now only loaded once from the standalone file by node-environment.ts. Also adds two defensive measures: - A global symbol guard that noops if a second installation is ever attempted from a separate module evaluation (e.g. Jest's module system re-evaluating an already-loaded module in the same process) - A reentrancy guard on the handler that noops if an underlying listener synchronously re-emits 'unhandledRejection'
Author
Parents
Loading