Open
Description
Link to the code that reproduces this issue
To Reproduce
- Create an instrumentation.ts file
- Above register(), add console.log("instrumentation runtime", process.env.NEXT_RUNTIME);
Current vs. Expected behavior
Current behaviour:
console shows: instrumentation runtime edge
Expected behaviour:
console shows: instrumentation runtime nodejs
I would assume that the default runtime (nodejs) would be used if not specified, as shown in the docs
I had to add export const runtime ='nodejs'
to force the instrumentation.ts file to run in the nodejs environment (Edit: this does not work, see below for more context)
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64
Binaries:
Node: 18.19.0
npm: 10.2.3
Yarn: 1.22.18
pnpm: 8.11.0
Relevant Packages:
next: 14.0.4
eslint-config-next: 14.0.4
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)
Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I just realised what the issue is:
- instrumentation.ts runs in the nodejs env when the server is first started, e.g. npm run dev
- When you make a change to the instrumentation.ts file, the server runs instrumentation.ts again, but in the edge env
Is this expected behaviour?