vercel / vercel/next.js

Diagnostics channel from node leak into edge environment in dev

Open
#81,063 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Instrumentation
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/happy-mclean-htz6qx

To Reproduce
  1. Start the application (next dev)
  2. Click on the button to trigger the edge API route
  3. See the console.log finished fetch node request to: https://github.com
Current vs. Expected behavior

The problem seems to be as follows:

  • Register a diagnostics channel subscription, which is a node-only API, in the register hook of instrumentation.ts.
  • Then, if you trigger fetch in an edge route, where diagnostics channel should not even be a thing, observe that it is still triggering the diagnostics channel (in the node env)

It seems that the simulated edge environment (?) in dev does not properly isolate the fetch diagnostics channel. This should not happen and leads to hard-to-debug problems with observability, where fetch requests from edge requests weirdly trigger code in the node environment.

Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.4.0-canary.103 // Latest available version is detected (15.4.0-canary.103).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.3.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Instrumentation

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and reproduce the behavior using next dev, instrumentation.ts, and the edge API route. Trace how the diagnostics channel registered in the Node environment observes the edge route's fetch. Done means edge requests no longer trigger the Node diagnostics subscription while Node requests retain their expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, node.js
Domain
backend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.