Open
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 ZEN SMP PREEMPT_DYNAMIC Tue, 08 Aug 2023 22:13:48 +0000
Binaries:
Node: 18.17.1
npm: 9.6.7
Yarn: 1.22.19
pnpm: 8.6.12
Relevant Packages:
next: 13.4.20-canary.2
eslint-config-next: 13.4.13
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.6
Next.js Config:
output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://github.com/SeriousBug/nextjs-error-repro
To Reproduce
Enable instrumentationHook
experimental feature, then in the instrumentation.ts
throw an error where the message
field is a getter. This will cause the error Cannot set property message of ... which has only a getter
. A similar error occurs if the error was not an object.
Describe the Bug
The bug is caused by this line which incorrectly assumes that the error must have a message
field, which results inside the catch block:
I encountered this issue because I was parsing data with Zod at the top level of instrumentation.ts
, which throws a custom error with a getter message
field.
Expected Behavior
A concise error message should still be displayed if the message
field can not be overwritten.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response