Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.112.2
Framework Version
Next.js 14.1.4
Link to Sentry event
https://playtnet.sentry.io/issues/5259621428
SDK Setup
Printed server-side Sentry config:
{
dsn:
'https://d66c28aa36164b0f873a60bd0556ac90@o4504684409782272.ingest.sentry.io/4504684413845504',
environment: 'development',
integrations: [
{
name: 'CaptureConsole',
setupOnce: [Function: setupOnce],
setup: [Function: setup]
},
{
name: 'OnUncaughtException',
setupOnce: [Function: setupOnce],
setup: [Function: setup]
},
{
name: 'OnUnhandledRejection',
setupOnce: [Function: setupOnce],
setup: [Function: setup]
},
Mongo {
name: 'Mongo',
_operations: [Array],
_describeOperations: true,
_useMongoose: false
},
Prisma { name: 'Prisma' }
],
tracesSampleRate: 0.02,
beforeSend: [Function: beforeSend],
release: '',
beforeSendTransaction: [Function: beforeSendTransaction]
}Notably, console capturing is set up with captureConsoleIntegration({ levels: ["warn", "error"] }) and the custom beforeSend* functions do not contain any logic that could set an event.level to 'error'
Steps to Reproduce
Some time around Thu 2024-04-25 console.traces started being captured with level:error.
We did not change our Sentry config, logging infrastructure, or relevant package versions. The Vercel/AWS Lambda Node version may or may not have changed during that time.
It could also be possible that not the logging but the pure act of capturing a stack trace (which console.trace does) is what's entering an event into Sentry?
Expected Result
console.trace calls do not cause an event in Sentry unless the console capturing integration is set up to do so.
Actual Result
console.trace calls cause a level:error event in Sentry (see example link to Sentry event)
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
- StatusShow more project fieldsWaiting for: Community
Activity
jeysal commentedon Apr 29, 2024
I don't know how easy it will be to track this down in case it doesn't reproduce in other Next.js apps but I can assist with that.
For now my hope is that you've already seen something like this or have a clue what may have suddenly changed mid last week, so that you already have an idea where the problem could be.
mydea commentedon Apr 29, 2024
Are you sure this is actually the result of a
console.trace, and not aconsole.error? We filter out all other console types in the capture console integration, so it must already be triggered as an error earlier 🤔 Could you check & paste one or another place from the source code that triggers this? So e.g.jeysal commentedon Apr 29, 2024
Yes, for example for one of the simplest trace logs https://playtnet.sentry.io/issues/5259621425 , the code is
where
loggeris imported from its definition asIt's really quite straightforward.
That's why I wondered whether perhaps it has nothing to do with
consoleat all, but perhaps the SDK is doing some magic onglobalThis.Erroror so that might mean that even the act of constructing a stack trace (whichconsole.traceprobably does internally) might result in a Sentry event.mydea commentedon Apr 30, 2024
Hmm, so I added some tests for this specifically here: #11830 and it seems to be working as expected 🤔
Look here: https://github.com/getsentry/sentry-javascript/pull/11830/files#diff-846c22f3c13c0f21374988eda6e64f0c844b2ba8c6561360b9050427b918faeeR70
This shows that
level: 'log'forconsole.trace.You can also see in the issue you linked, that there is also a breadcrumb which also shows level=error:
This basically shows that this comes not from the
captureConsoleintegration, but is already captured aslevel=errorbefore that.You can see here: https://github.com/getsentry/sentry-javascript/blob/v7/packages/utils/src/instrument/console.ts#L32 how we actually instrument the console. I can't really see how that would lead to the wrong level being captured for
console.trace🤔1 remaining item
test(browser): Add test for captureConsole (#11831)
jeysal commentedon Apr 30, 2024
I'll try to reduce the issue a bit to track down the cause.
One thing that's also strange is that at the same time as this started happening, in our log aggregator
console.tracelogs started showing up with a full stack trace like they in local Node.js, which before that they did not. That's what made me think this might come from an infrastructure change on Vercel/AWS functions.I was hoping ideally it would turn out to just be a Node.js minor bump or so that changed behavior and caused this, but it looks like most people aren't seeing this behavior like we are 😄
getsantry commentedon Jun 6, 2024
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label
Waiting for: Community, I will leave it alone ... forever!"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
jeysal commentedon Aug 22, 2024
Don't know what fix happened meanwhile, but after removing the Inbound Filter workaround today, it seems those
Trace:events are magically not coming in anymore