vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.5k stars 26.81k forks source link

instrumentation effect problem #57880

Open justLuiz opened 11 months ago

justLuiz commented 11 months ago

Link to the code that reproduces this issue

Link to the code that reproduces this issue

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

whit canary 13

Current vs. Expected behavior

Module effects are inaccessible without using a global variable

Verify canary release

Provide environment information

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

tachang commented 11 months ago

Doesn't the instrumentation code load before any next.js code so it doesn't run in the same context?

dengBox commented 11 months ago

+1, I hope Next can provide a global runtime variable API