Skip to content

Critical dependency warning with require-in-the-middle after upgrading to Sentry 8.52.0 in Next.js app #15209

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

Closed
3 tasks done
danielkoller opened this issue Jan 29, 2025 · 41 comments

Comments

@danielkoller
Copy link

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.52.0

Framework Version

React 19.0.0 & Next.js 15.1.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Create a Next.js application
  2. Install latest @sentry/nextjs (8.52.0)
  3. Run the development server
  4. Observe the critical dependency warning

Expected Result

No critical dependency warnings during development server startup.

Actual Result

 ⚠ ./node_modules/.pnpm/[email protected]/node_modules/require-in-the-middle/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/require-in-the-middle/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@opentelemet_usgluomwp3va5k3mad5pbwdxfm/node_modules/@sentry/opentelemetry/build/cjs/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@opentelemetry+ins_fvm7vkuyikfkbj6gbt6uu4g4sq/node_modules/@sentry/nextjs/build/cjs/server/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@opentelemetry+ins_fvm7vkuyikfkbj6gbt6uu4g4sq/node_modules/@sentry/nextjs/build/cjs/index.server.js
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 29, 2025
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Jan 29, 2025
@lforst
Copy link
Member

lforst commented Jan 29, 2025

Hi, we'll resolve this warning with the next release!

@danielkoller
Copy link
Author

Awesome, thanks @lforst!

@sousounibajis
Copy link

Hi @lforst,

Since upgrading to @sentry/[email protected], I’m encountering the same "require-in-the-middle" Critical Dependency Warning in Next.js. I saw that you mentioned a fix is planned for the next release.

For the interim solution, could you clarify: 1️⃣ Which is the latest stable release that does not have this issue? Should we downgrade to @sentry/[email protected], or is there a better version? 2️⃣ Would you recommend suppressing the warning using "ignoreWarnings" in next.config.js, or is downgrading a better approach? 3️⃣ What’s the estimated timeline for the fix in the next release?

Thanks in advance for your help! (cc: @getsantry @danielkoller)

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

@sousounibajis just jumping in for Luca real quick:

  • 8.51.0 should still be good as we only noticed this with 8.52.0
  • I'm starting the 8.52.1 release right now which fixes this issue. It should be out in a couple of hours.

Lms24 added a commit that referenced this issue Jan 30, 2025
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

8.52.1 was just released, let me know if the error still persists!

Sorry for the troubles everyone!

@colaquecez
Copy link

colaquecez commented Jan 30, 2025

Hey, I'm getting the same error using 8.51.0

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-PVBRMQBZ.js
../../node_modules/@prisma/instrumentation/dist/index.js
../../node_modules/@sentry/node/build/cjs/integrations/tracing/prisma.js
../../node_modules/@sentry/node/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx

../../node_modules/require-in-the-middle/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
../../node_modules/require-in-the-middle/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/index.js
../../node_modules/@sentry/opentelemetry/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/server/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx
 GET / 200 in 49083ms
 ⚠ ../../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-PVBRMQBZ.js
../../node_modules/@prisma/instrumentation/dist/index.js
../../node_modules/@sentry/node/build/cjs/integrations/tracing/prisma.js
../../node_modules/@sentry/node/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx
yarn why @prisma/instrumentation       
yarn why v1.22.22
[1/4] 🤔  Why do we have the module "@prisma/instrumentation"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@prisma/[email protected]"
info Reasons this module exists
   - "@sentry#nextjs#@sentry#node" depends on it
   - Hoisted from "@sentry#nextjs#@sentry#node#@prisma#instrumentation"
info Disk size without dependencies: "1.98MB"
info Disk size with unique dependencies: "7.83MB"
info Disk size with transitive dependencies: "23.56MB"
info Number of shared dependencies: 23
✨  Done in 0.46s.

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

I'm getting the same error using 8.51.0

@colaquecez does 8.52.1 fix it for you?

@colaquecez
Copy link

colaquecez commented Jan 30, 2025

Hey @Lms24, it doesn't:

"@sentry/nextjs": "8.52.1"

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-PVBRMQBZ.js
../../node_modules/@prisma/instrumentation/dist/index.js
../../node_modules/@sentry/node/build/cjs/integrations/tracing/prisma.js
../../node_modules/@sentry/node/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx

../../node_modules/require-in-the-middle/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
../../node_modules/require-in-the-middle/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/index.js
../../node_modules/@sentry/opentelemetry/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/server/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx
 GET / 200 in 52182ms
 ⚠ ../../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-PVBRMQBZ.js
../../node_modules/@prisma/instrumentation/dist/index.js
../../node_modules/@sentry/node/build/cjs/integrations/tracing/prisma.js
../../node_modules/@sentry/node/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/global-error.tsx

../../node_modules/require-in-the-middle/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
../../node_modules/require-in-the-middle/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
../../node_modules/@opentelemetry/instrumentation/build/esm/index.js
../../node_modules/@sentry/opentelemetry/build/cjs/index.js
../../node_modules/@sentry/nextjs/build/cjs/server/index.js
../../node_modules/@sentry/nextjs/build/cjs/index.server.js
[1/4] 🤔  Why do we have the module "@prisma/instrumentation"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@prisma/[email protected]"
info Reasons this module exists
   - "@sentry#nextjs#@sentry#node" depends on it
   - Hoisted from "@sentry#nextjs#@sentry#node#@prisma#instrumentation"
info Disk size without dependencies: "1.98MB"
info Disk size with unique dependencies: "7.83MB"
info Disk size with transitive dependencies: "23.56MB"
info Number of shared dependencies: 23
✨  Done in 0.48s.

@Lms24 Lms24 reopened this Jan 30, 2025
@KarolisAntanas
Copy link

KarolisAntanas commented Apr 29, 2025

Having the same warning and none of the mentioned methods silenced it.

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Import trace for requested module:
./node_modules/require-in-the-middle/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/@sentry/node/build/cjs/otel/instrument.js
./node_modules/@sentry/node/build/cjs/index.js
./node_modules/@sentry/nextjs/build/cjs/index.server.js
./app/error.tsx

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 29, 2025
@Lms24
Copy link
Member

Lms24 commented Apr 29, 2025

@KarolisAntanas (or anyone else still affected by this error): Can you please provide a minimal reproduction? We tried reproducing this multiple times ourselves and couldn't do so.

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Apr 29, 2025
@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 May 5, 2025
@haydnjm
Copy link

haydnjm commented May 5, 2025

Never mind - my issue was related to my usage of withSentryConfig. Fixed that up and I'm not getting the warning anymore.

@tkodev
Copy link

tkodev commented May 8, 2025

Never mind - my issue was related to my usage of withSentryConfig. Fixed that up and I'm not getting the warning anymore.

How did you fix it?

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 May 8, 2025
@chaodonghu
Copy link

chaodonghu commented May 8, 2025

Never mind - my issue was related to my usage of withSentryConfig. Fixed that up and I'm not getting the warning anymore.

@haydnjm Can you clarify how you fixed it? I'm getting the same error right now as well

Error: Cannot find module 'require-in-the-middle'
Require stack:
- /var/task/packages/service/.next/server/app/page.js
- /var/task/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-dom@1_lgmiccyhb4drfv4bvfqhftpu5e/node_modules/next/dist/compiled/next-server/server.runtime.prod.js
- /var/task/packages/service/___next_launcher.cjs
- /opt/rust/nodejs.js

Update: Just following up on this the errors in the development console can be fixed through configuring the next.config.js file

next.config.js

...
 webpack: (config) => {
    config.externals = config.externals || [];
    config.externals.push("require-in-the-middle");
    return config;
  }
...

I also installed require-in-the-middle as a devDepenency and it seemed to solve the issue in both our e2e tests and CI/CD pipeline

package.json

  "devDependencies": {
...
    "require-in-the-middle": "^7.5.2",
...
  },

@chargome
Copy link
Member

If you still encounter this issue please review the troubleshooting steps in our documentation or check this issue history for additional solutions and workarounds.

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

No branches or pull requests