-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Maximum call stack size exceeded
after upgrading 7.114.0 -> 8.27.0
#13519
Comments
Maximum call stack size exceeded
after upgrading 7.114.0 -> 8.27.0
Hi, thanks for writing in! Are you adding any event processors somewhere? |
Sorry, I should have included those. We have a basic traces sampler in the client and server config: tracesSampler = (samplingContext: SamplingContext) => {
if (
samplingContext.transactionContext.name === "GET /api/health-check" ||
samplingContext.transactionContext.name === "GET /api/metrics/prometheus"
) {
return 0;
} else {
return defaultTraceSampleRate; // number parsed from env variable
}
}; And a We don't use anything like |
Hmm, I don't see anything anywhere that might cause this. Can you reproduce this with a minimal setup that you could share with us? |
Honestly, no. This is happening in production for us and since the stack trace is entirely Sentry's own modules I have absolutely no idea where this error is coming from. I can link more issues for the same problem that haven't been grouped together? https://go-city.sentry.io/issues/5768588849 We have one other |
Just been digging around existing issues further and came across this comment:
Since we are self hosting Next.js in Node (no edge) I wonder if |
I think this could be the issue. In Next 14.1.4, Now that It sounds like they've fixed this in Next 15 Canary: vercel/next.js#51450 (comment) |
All of this smells very funky to me. Can you double check that Sentry.init() is not called over and over again through imports or anything? That is usually what leads to these kinds of errors if there aren't any explicit |
Yes, I think that's what's happening. We have an export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("@/instrumentation.node");
}
if (process.env.NEXT_RUNTIME === "edge") {
await import("@/instrumentation.edge");
}
} Which effectively does this: export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
Sentry.init(...)
}
if (process.env.NEXT_RUNTIME === "edge") {
Sentry.init(...)
}
} If you make the reasonable assumption What I found actually happens, is Next.js runs register twice, and changes the environment variable. It runs once with This likely wasn't an issue for us in v7 since we were using It may be worth flagging this in the docs? https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files |
@harry-gocity it's fine that register is called twice as long as things are guarded with the I fear this is very hard to debug without having something locally reproducible or at least access to the relevant code. I am happy to take a quick look at your repo if you provide access. We ensure confidentiality. |
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.27.0
Framework Version
React 18.3, Next.js 14.1.4
Link to Sentry event
https://go-city.sentry.io/issues/5767473230
Reproduction Example/SDK Setup
Steps to Reproduce
We just upgraded from Sentry 7.114.0 to 8.27.0 and have since had a few 'Maximum call stack size exceeded' errors appear in Sentry that trace back to
/usr/app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/utils/build/cjs/syncpromise.js
and/usr/app/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/build/cjs/eventProcessors.js
in a loop.To upgrade from 7 to 8 we:
sentry.server.config.ts
andsentry.edge.config.ts
to Next.jsinstrumentation.ts
(We don't actually use the edge runtime, we are self hosting on Node, but we moved the edge config anyway)SentryWebpackPluginOptions
andUserSentryOptions
into a singleSentryBuildOptions
param forwithSentryConfig
httpClientIntegration
andreplayIntegration
with the functional alternativeExpected Result
We didn't see these issues before but we do now. All events seem to be happening Node, none from the browser.
Actual Result
No new errors 🙏
The text was updated successfully, but these errors were encountered: