Repository: next.js
Issue: instrumentation effect problem
Labels: bug,Instrumentation

### Link to the code that reproduces this issue

[Link to the code that reproduces this issue](https://codesandbox.io/p/sandbox/nextjs-instrumentation-effect-problem-forked-22p8x7?file=%2Fsrc%2Fapp%2Fapi%2Feffect%2Froute.ts%3A1%2C1&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clofnxuip000a2v6givwhxwya%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clofnxuio00032v6gorj3dcgh%2522%253A%257B%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%252C%2522activeTabId%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Finstrumentation.ts%2522%252C%2522id%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fconfig%252Fsome-effect.ts%2522%252C%2522id%2522%253A%2522clofq86ah01972v6gq5hyfu63%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fapp%252Fapi%252Feffect%252Froute.ts%2522%252C%2522id%2522%253A%2522clofq88ah01bc2v6gzo4kfq72%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%257D%252C%2522clofnxuio00092v6g2bjlfcl3%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A3000%252C%2522path%2522%253A%2522%252Fapi%252Feffect%2522%257D%255D%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%252C%2522activeTabId%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%257D%252C%2522clofnxuio00072v6gmw43p2wo%2522%253A%257B%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%252C%2522activeTabId%2522%253A%2522clofqsfom01ks2v6gjcjbjvgx%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00042v6gmw9hsn54%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00052v6gzmef3tie%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00062v6gqvfcta12%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522lint%2522%257D%252C%257B%2522id%2522%253A%2522clofo0wt800ue2v6gf5wgvrue%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofo0x0800o6d9gg5sko3uyn%2522%257D%252C%257B%2522id%2522%253A%2522clofqsfom01ks2v6gjcjbjvgx%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofqsfu500oqd9ggb2hdchwq%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

### To Reproduce

1. create a module with an effect
2. run this module on instrumentation
3. try access in your routes

samples:

[with latest 13](https://codesandbox.io/p/sandbox/nextjs-instrumentation-effect-problem-forked-22p8x7?file=%2Fsrc%2Fapp%2Fapi%2Feffect%2Froute.ts%3A1%2C1&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clofnxuip000a2v6givwhxwya%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clofnxuio00032v6gorj3dcgh%2522%253A%257B%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%252C%2522activeTabId%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Finstrumentation.ts%2522%252C%2522id%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fconfig%252Fsome-effect.ts%2522%252C%2522id%2522%253A%2522clofq86ah01972v6gq5hyfu63%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fapp%252Fapi%252Feffect%252Froute.ts%2522%252C%2522id%2522%253A%2522clofq88ah01bc2v6gzo4kfq72%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%257D%252C%2522clofnxuio00092v6g2bjlfcl3%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A3000%252C%2522path%2522%253A%2522%252Fapi%252Feffect%2522%257D%255D%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%252C%2522activeTabId%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%257D%252C%2522clofnxuio00072v6gmw43p2wo%2522%253A%257B%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%252C%2522activeTabId%2522%253A%2522clofqsfom01ks2v6gjcjbjvgx%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00042v6gmw9hsn54%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00052v6gzmef3tie%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00062v6gqvfcta12%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522lint%2522%257D%252C%257B%2522id%2522%253A%2522clofo0wt800ue2v6gf5wgvrue%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofo0x0800o6d9gg5sko3uyn%2522%257D%252C%257B%2522id%2522%253A%2522clofqsfom01ks2v6gjcjbjvgx%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofqsfu500oqd9ggb2hdchwq%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

[whit canary 13](https://codesandbox.io/p/sandbox/nextjs-instrumentation-effect-problem-forked-pvwzwd?file=%2Fsrc%2Finstrumentation.ts&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clofnxuip000a2v6givwhxwya%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clofnxuio00032v6gorj3dcgh%2522%253A%257B%2522id%2522%253A%2522clofnxuio00032v6gorj3dcgh%2522%252C%2522activeTabId%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Finstrumentation.ts%2522%252C%2522id%2522%253A%2522clofq84jv01722v6gwbo7uxzf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fconfig%252Fsome-effect.ts%2522%252C%2522id%2522%253A%2522clofq86ah01972v6gq5hyfu63%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Fapp%252Fapi%252Feffect%252Froute.ts%2522%252C%2522id%2522%253A%2522clofq88ah01bc2v6gzo4kfq72%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%257D%252C%2522clofnxuio00092v6g2bjlfcl3%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A3000%252C%2522path%2522%253A%2522%252Fapi%252Feffect%2522%257D%255D%252C%2522id%2522%253A%2522clofnxuio00092v6g2bjlfcl3%2522%252C%2522activeTabId%2522%253A%2522clofnxuio00082v6gj7fz88zy%2522%257D%252C%2522clofnxuio00072v6gmw43p2wo%2522%253A%257B%2522id%2522%253A%2522clofnxuio00072v6gmw43p2wo%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clofnxuio00042v6gmw9hsn54%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00052v6gzmef3tie%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%257D%252C%257B%2522id%2522%253A%2522clofnxuio00062v6gqvfcta12%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522lint%2522%257D%252C%257B%2522id%2522%253A%2522clofo0wt800ue2v6gf5wgvrue%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofo0x0800o6d9gg5sko3uyn%2522%257D%252C%257B%2522id%2522%253A%2522clofqsfom01ks2v6gjcjbjvgx%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clofqsfu500oqd9ggb2hdchwq%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clofnxuio00042v6gmw9hsn54%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

### Current vs. Expected behavior

Module effects are inaccessible without using a global variable

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
Binaries:
  Node: 16.17.0
  npm: 8.15.0
  Yarn: 1.22.19
  pnpm: 7.1.0
Relevant Packages:
  next: 13.5.6
  eslint-config-next: 12.0.9
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 4.8.4
Next.js Config:
  output: standalone
```


### Which area(s) are affected? (Select all that apply)

App Router

### Additional context

Tested with nodejs 20, same problem