Open victorcarvalhosp opened 2 days ago
Hi @victorcarvalhosp thanks for writing in.
From your config and logs I spot a few things
1) the sentry
field should not be used anymore, instead pass that as a new object as second argument to withSentryConfig
2) It looks like the instrumentation file isn't detected. My guess is this is because your renaming of the instrumentation file. This is a convention by nextjs and by renaming it, it won't be imported correctly to the best of my knowledge. Additionally, Sentry follows this convention and only looks for files named instrumentation.ts|js
, which is why you are seeing those logs like
[@sentry/nextjs] It appears you've configured a
sentry.edge.config.js
file. Please ensure to put this file's content into theregister()
function of a Next.js instrumentation hook instead. To ensure correct functionality of the SDK,Sentry.init
must be called insideinstrumentation.ts
. Learn more about setting up an instrumentation hook in Next.js: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation. You can safely delete thesentry.edge.config.js
file afterward.
Can you try fixing these and see if that helps?
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.30.0
Framework Version
14.2.5
Link to Sentry event
No response
Reproduction Example/SDK Setup
Our build starts to fail as soon as we start importing sentry.server.config or sentry.edge.config on our instrumentation file.
We're using the default code that is provided in the wizard install, the only difference is that we renamed the instrumentation.js to instrumentation.api.ts - as we're using
pageExtensions: ['page.tsx', 'page.ts', 'api.tsx', 'api.ts']
, but I believe this is not related to the issue, as instrumentation is working fine if we try with some other library like@vercel/otel
for example.This is the error that we have when we run the build command:
This is our next.config:
If we comment everything that is inside sentry.edge.config and sentry.server.config the build is successful and Sentry works fine on client side - don't work on server side for obvious reasons as we commented the code.
Steps to Reproduce
Added instrumentation.ts inside src folder, and added sentry.edge.config.js and sentry.server.config.js files and added instrumentationHook on next.config.js:
instrumentation.ts:
sentry.server.config.js:
sentry.edge.config.js:
We tried to make it work with multiple approaches, but none of them worked unfortunately.
Expected Result
build should work and errors thrown from the API should go to Sentry successfully.
Actual Result
build fails. Complete log below: