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

Critical Dependency Warning After Upgrading to @sentry/nextjs v8 #12077

Closed
3 tasks done
saraluk opened this issue May 16, 2024 · 6 comments · Fixed by #12144
Closed
3 tasks done

Critical Dependency Warning After Upgrading to @sentry/nextjs v8 #12077

saraluk opened this issue May 16, 2024 · 6 comments · Fixed by #12144

Comments

@saraluk
Copy link

saraluk commented May 16, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.1.0

Framework Version

next 14.2.3

Link to Sentry event

No response

SDK Setup

Sentry.init({
  dsn: "change me",
  tracesSampleRate: 1,
  debug: false,
  integrations: [
    Sentry.feedbackIntegration({
      autoInject: false,
    }),
  ],
});

Steps to Reproduce

Upgrade @sentry/nextjs from v7.113.0 to v8.1.0 and run the project build process

Expected Result

The build process should complete without warnings related to critical dependencies.

Actual Result

After upgrading to @sentry/nextjs version 8, I encountered the following warning in the build logs:

⚠ ./node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/@prisma/instrumentation/node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/@prisma/instrumentation/dist/chunk-64MZJIQ5.js
./node_modules/@prisma/instrumentation/dist/index.js
./node_modules/@sentry/node/cjs/integrations/tracing/prisma.js
./node_modules/@sentry/node/cjs/index.js
./node_modules/@sentry/nextjs/cjs/index.server.js
./app/global-error.tsx

@mydea
Copy link
Member

mydea commented May 16, 2024

Hmm, let's see if this: #12081 possibly fixes this 🤔

@gusfune
Copy link

gusfune commented May 17, 2024

I can also confirm this is going on 8.2.1 version.

@MarwanAlsoltany
Copy link

I can also confirm this is going on 8.2.1 version.

+1

@lforst
Copy link
Member

lforst commented May 21, 2024

This warning can be safely ignored. In theory, the SDK should add an ignore rule for this warning. I wonder why that doesn't work for you 🤔

function addOtelWarningIgnoreRule(newConfig: WebpackConfigObjectWithModuleRules): void {
const ignoreRule = { module: /@opentelemetry\/instrumentation/ };
if (newConfig.ignoreWarnings === undefined) {
newConfig.ignoreWarnings = [ignoreRule];
} else if (Array.isArray(newConfig.ignoreWarnings)) {
newConfig.ignoreWarnings.push(ignoreRule);
}
}

Would you mind sharing your next.config.js? Can you try adding the following to your ignoreWarnings in your Next.js webpack config?

[
    { module: /@opentelemetry\/instrumentation/, message: /Critical dependency/ },
    { module: /@prisma\/instrumentation/, message: /Critical dependency/ },
]

@GiancarlosIO
Copy link

Hi there. I'm using @sentry/nextjs v8.7.0 and I still get the warning in the console:

- warn ../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/src/platform/node/instrumentation.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/src/platform/node/instrumentation.js
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/src/platform/node/index.js
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/src/platform/index.js
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/src/index.js
../../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@opentelemetr_easlgnajsmadvvyfptwg27pvmy/node_modules/@sentry/opentelemetry/cjs/index.js
../../node_modules/.pnpm/@[email protected]/node_modules/@sentry/node/cjs/index.js
../../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@opentelemetry+api@1_n5hycvwuc2wadypxzgqutrwu2y/node_modules/@sentry/nextjs/cjs/index.server.js

Is the issue closed because the fix is going to be released in a new version? 🤔

@lforst
Copy link
Member

lforst commented Jun 5, 2024

@GiancarlosIO It's not really a fix we published but we are ignoring the warning automatically. The code for this is here:

function addOtelWarningIgnoreRule(newConfig: WebpackConfigObjectWithModuleRules): void {

I struggle a bit to understand how this is happening. Would you mind sharing reproduction? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants