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 with require-in-the-middle after upgrading to Sentry 8.52.0 in Next.js app #15209

Closed
3 tasks done
danielkoller opened this issue Jan 29, 2025 · 17 comments
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

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
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

thanks for the notice, I reopened the issue and will take another look

@danielkoller
Copy link
Author

8.52.1 fixed it for me, thanks!

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@sftsk
Copy link

sftsk commented Jan 30, 2025

I had this problem yesterday and it seemed to be an issue with require-in-the-middle. They just had an update (v7.5.0) and if that gets installed through this package the error appears. I manually set my build to use v7.4.0 and got rid of the error for the time being. before I did that even downgrading this package didn't get the error to vanish.

@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

Hmm so I can't reproduce this on @sentry/[email protected] and [email protected] (which I didn't install manually but is being pulled in as a transitive dependency from the SDK).

Here's my reproduction attempt: https://github.com/Lms24/gh-sentry-javascript-15209-next-dep-warning

@colaquecez can you check your lock file if all Sentry packages were updated to 8.52.1? If this is happening in CI, any chance that a dependency cache (or another caching mechanism) is still using the old version?

EDIT: I meant @sentry/[email protected], not @sentry/[email protected]; sorry for the confusion!

@colaquecez
Copy link

Hey @Lms24, I reverted my yarn.lock file, and now everything is working again. It looks like one of the dependencies was causing the issue. I'll investigate it later. Thanks a lot for your help!

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 30, 2025
@Lms24
Copy link
Member

Lms24 commented Jan 30, 2025

Glad to hear it's working now! Then I'll close the issue again. Please let me know if anyone is still experiencing this warning.

@Stoffberg
Copy link

I can confirm that changing the version from 8.52.0 -> 8.52.1 fixes the problem.

@tillka
Copy link

tillka commented Jan 31, 2025

Just found this thread while googling my error. I used to have the one outlined above. After updating to v8.52.1 it is the following now:

./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package require-in-the-middle can't be external
The request require-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install require-in-the-middle from the project directory.

The fix outlined in the Vercel Issues area did not work for me (vercel/next.js#68805 (comment))

  • "next": "15.1.6"
  • "@sentry/nextjs": "^8.52.1"

Let me know if you need more info.

@lforst
Copy link
Member

lforst commented Feb 3, 2025

@tillka your issue is a different one, most likely related to turbopack. Please check: #8105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Archived in project
Development

No branches or pull requests

8 participants