next.js: [NEXT-1100] unhandledRejection: Error [TypeError]: trace.getSpan is not a function

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 20.6.0: Sun Nov  6 23:17:00 PST 2022; root:xnu-7195.141.46~1/RELEASE_X86_64
    Binaries:
      Node: 18.12.1
      npm: 9.3.1
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.3.1-canary.2
      eslint-config-next: 13.3.0
      react: 18.2.0
      react-dom: 18.2.0

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

CLI (create-next-app)

Link to the code that reproduces this issue

https://github.com/dossy/nextjs-trace-getSpan-is-not-a-function

To Reproduce

Provided by https://github.com/vercel/next.js/issues/48118#issuecomment-1556428577:

reproduce with a yarn workspaces monorepo.

Check this one out here: jamesopti/next-tracespan-error-reproduction

The packages/server has “@opentelemetry/api”: “^0.18.1”

The packages/client is a brand new create next app.

Describe the Bug

Trying to access the app results in an unhandledRejection: Error [TypeError]: trace.getSpan is not a function error:

$ yarn dev
yarn run v1.22.19
$ next dev
warn  - Port 3000 is in use, trying 3001 instead.
ready - started server on 0.0.0.0:3001, url: http://localhost:3001
(node:53803) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
event - compiled client and server successfully in 1821 ms (170 modules)
wait  - compiling / (client and server)...
event - compiled client and server successfully in 467 ms (217 modules)
error - unhandledRejection: Error [TypeError]: trace.getSpan is not a function
    at NextTracerImpl.getActiveScopeSpan ([REDACTED]/create-next-app-sample/node_modules/next/dist/server/lib/trace/tracer.js:50:22)
    at NextTracerImpl.trace ([REDACTED]/create-next-app-sample/node_modules/next/dist/server/lib/trace/tracer.js:69:103)
    at DevServer.handleRequest ([REDACTED]/create-next-app-sample/node_modules/next/dist/server/base-server.js:166:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DevServer.handleRequest ([REDACTED]/create-next-app-sample/node_modules/next/dist/server/dev/next-dev-server.js:839:16) {
  digest: undefined
}

Expected Behavior

The home page should render in the browser.

Which browser are you using? (if relevant)

Chrome Version 111.0.5563.146 (Official Build) (x86_64)

How are you deploying your application? (if relevant)

locally

From SyncLinear.com | NEXT-1100

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 24 (8 by maintainers)

Most upvoted comments

It appears that @opentelemetry/api is a peerDependency now, but the docs dont indicate as much: https://github.com/vercel/next.js/blob/v13.4.1/packages/next/package.json#L95