Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sideloading OpenTelemetry in Node.js breaks Next.js #21861

Closed
DVN237294 opened this issue Feb 4, 2021 · 4 comments
Closed

Sideloading OpenTelemetry in Node.js breaks Next.js #21861

DVN237294 opened this issue Feb 4, 2021 · 4 comments
Labels
bug Issue was opened via the bug report template.

Comments

@DVN237294
Copy link

What version of Next.js are you using?

10.0.6

What version of Node.js are you using?

14.15.1

What browser are you using?

Chrome, Firefox

What operating system are you using?

Windows

How are you deploying your application?

node --trace-deprecation -r ./telemetry.js node_modules/next/dist/bin/next dev

Describe the Bug

Running OpenTelemetry in another node module alongside next.js seems to break telemetry in next.js, as it currently relies on an outdated version of opentelemetry, causing import conflicts as the side-loaded module has already imported a newer version of opentelemetry that next.js doesn't support.

Next.js fails with:

error - ./node_modules/next/dist/client/polyfills.js
TypeError: _tracer.tracer.withSpan is not a function

Expected Behavior

Next.js to run, even with version conflicts with telemetry disabled through npx next telemetry disable

One solution would be to update opentelemetry to the newest version. The better solution would be exclude any references to opentelemetry when telemetry is disabled.

To Reproduce

In windows, to create a minimally failing project:
npx create-next-app nextjs-opentelemetry-issue --use-yarn
cd nextjs-opentelemetry-issue
npx next telemetry disable
yarn add @opentelemetry/node @opentelemetry/plugin-https
notepad telemetry.js add and save:

"use strict";

const { NodeTracerProvider } = require("@opentelemetry/node");

const provider = new NodeTracerProvider();
provider.register();

run the project with telemetry.js sideloaded:
node --trace-deprecation -r ./telemetry.js node_modules/next/dist/bin/next dev

@DVN237294 DVN237294 added the bug Issue was opened via the bug report template. label Feb 4, 2021
@timneutkens
Copy link
Member

Feel free to send a PR to upgrade.

@turneand
Copy link
Contributor

turneand commented Jun 8, 2021

We had a similar issue to this with the latest code (10.1.1), but it appears that opentelemetry isn't actually required anymore (removed in #22713), but the opentelemetry/api dependency is still there. I've raised PR #25900 to remove it, so please let me know if that's appropriate to remove and there's not some other reason it's included.

@timneutkens
Copy link
Member

This solved by #25900 👍 Thanks @turneand!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants