vercel / next.js

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

instrumentationHook breaks when importing server-only module #50319

Open gaetansnl opened 1 year ago

gaetansnl commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Wed Aug 25 23:20:18 UTC 2021
    Binaries:
      Node: 18.1.0
      npm: 8.8.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.4.4-canary.10
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

https://codesandbox.io/p/sandbox/elegant-hopper-dd2j6i?file=undefined

To Reproduce

Just create instrumentaiton.ts and call server-only module

Describe the Bug

You're importing a component that needs server-only. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.

Expected Behavior

It works

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

adentranter commented 7 months ago

can confirm is real bug.