-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Labels
InstrumentationRelated to Next.js Instrumentation.Related to Next.js Instrumentation.RuntimeRelated to Node.js or Edge Runtime with Next.js.Related to Node.js or Edge Runtime with Next.js.
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/pensive-feynman-lfsfss?file=%2Finstrumentation.ts
To Reproduce
- Start the application (npm run dev)
- Watch the console output.
Current vs. Expected behavior
Console output says:
$ next dev
▲ Next.js 15.4.0-canary.5
- Local: http://localhost:3000
- Network: http://172.17.0.2:3000
✓ Starting...
✓ Compiled /instrumentation in 573ms (22 modules)
[TypeError: Cannot set property message of [object Object] which has only a getter]
It is correct behaviour that an error occurs since the file instrumentation.ts results in an error when loaded.
Problem is that the actual error (in our case a zod error that occurs when the environment is parsed) is discarded, and a TypeError with no hint towards the actual error is thrown instead.
Reason is line 479 in next-dev-server.js:
async loadInstrumentationModule() {
let instrumentationModule;
if (this.actualInstrumentationHookFile && await this.ensurePage({
page: this.actualInstrumentationHookFile,
clientOnly: false,
definition: undefined
}).then(()=>true).catch(()=>false)) {
try {
instrumentationModule = await require((0, _path.join)(this.distDir, 'server', _constants.INSTRUMENTATION_HOOK_FILENAME));
} catch (err) {
// Here is the error:
err.message = `An error occurred while loading instrumentation hook: ${err.message}`;
throw err;
}
}
This line assumes hat the message property of the received error is writable, which may not be the case.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 28381
Available CPU cores: 16
Binaries:
Node: 22.10.0
npm: 10.9.0
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.3.0 // There is a newer version (15.3.1) available, upgrade recommended!
eslint-config-next: 15.3.0
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: standalone
⚠ There is a newer version (15.3.1) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issueWhich area(s) are affected? (Select all that apply)
Instrumentation, Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
Metadata
Metadata
Assignees
Labels
InstrumentationRelated to Next.js Instrumentation.Related to Next.js Instrumentation.RuntimeRelated to Node.js or Edge Runtime with Next.js.Related to Node.js or Edge Runtime with Next.js.