You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Next.js, when you reject a Promise with a non-Error object, the stack trace is not provided, making debugging harder. This is because JavaScript only includes a stack trace for Error objects. The solution is to reject the Promise with an Error object.
Example:
// Incorrect approachreturnPromise.reject({message: 'Something went wrong'});// Correct approachreturnPromise.reject(newError('Something went wrong'));
Link to the code that reproduces this issue
https://github.com/samijaber/nextjs-reject-bug-repro/
To Reproduce
npm run dev
/
and see error messageCurrent vs. Expected behavior
When a Promise reject has an Error reason:
When a Promise reject has a non-Error reason (an arbitrary object):
note how we lose information on where the rejection is coming from.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.11.0 npm: 10.2.4 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 15.2.3 // Latest available version is detected (15.2.3). eslint-config-next: N/A react: 19.0.0 react-dom: 19.0.0 typescript: 5.8.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Error Handling
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: