Skip to content

RangeError: Maximum call stack size exceeded in @sentry/remix server instrumentation #16075

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
badeleux opened this issue Apr 16, 2025 · 7 comments · Fixed by #16136
Closed
3 tasks done
Assignees
Labels

Comments

@badeleux
Copy link

badeleux commented Apr 16, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

9.12.0

Framework Version

Remix 2.16.5

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from "@sentry/remix";

const { SENTRY_DSN, ENVIRONMENT, NODE_ENV } = process.env;

if (NODE_ENV === "production") {
	console.info("Initializing Sentry");
	Sentry.init({
		dsn: SENTRY_DSN,
		tracesSampleRate: 0.3,
		profilesSampleRate: 0.1,
		autoInstrumentRemix: true,
		environment: ENVIRONMENT,
		sendDefaultPii: true,
                 integrations: [nodeProfilingIntegration(), Sentry.prismaIntegration()],
		beforeSendTransaction: (transaction) => {
			if (transaction.request?.url.endsWith("js.map")) return null;
			return transaction;
		},
		ignoreTransactions: ["healthcheck"],
	});
}

Environment
Node.js: v20.19.0
Sentry Remix SDK version: 9.12.0
Using ZenStack enhanced Prisma client
Using pnpm package manager

Steps to Reproduce

  1. Set up a Remix application with Sentry integration
  2. Configure Sentry server instrumentation in instrument.server.mjs
  3. Run the application under load or for an extended period
  4. Observe that occasionally the server crashes with the following error:
/myapp/node_modules/.pnpm/@sentry+remix@9.12.0_@opentelemetry+context-async-hooks@1.30.1_@opentelemetry+api@1.9.0__@ope_uinifbjcggxueklhweoo2zo2yi/node_modules/@sentry/remix/build/cjs/server/instrumentServer.js:167
    return async function ( args) {
                          ^
RangeError: Maximum call stack size exceeded

Expected Result

No crash.

Actual Result

Crash.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 16, 2025
@linear linear bot added the Bug label Apr 16, 2025
@lforst
Copy link
Member

lforst commented Apr 16, 2025

Thanks for writing in! Are there any more stack frames shown in the error message? I'd like to understand where we are potentially calling things too deeply.

@badeleux
Copy link
Author

Unfortunately nothing else.

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

lforst commented Apr 16, 2025

That is odd. Can you check that you don't have any addEventProcessor calls in your application or that you are not calling Sentry.init() over and over again?

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Apr 23, 2025
@badeleux
Copy link
Author

Sentry.init() is definitely called once. We don't use addEventProcessor

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

jvc9109 commented Apr 25, 2025

Hello we are facing the same crash with SDK v9.13 and remix v2.16.5

app/node_modules/@sentry/remix/build/cjs/server/instrumentServer.js:167 

return async function ( args) {
^
RangeError: Maximum call stack size exceeded

To make the init in entry.server.tsx as suggested in READ.ME, makes the backend reporting stop working.

Copy link
Member

lforst commented Apr 25, 2025

We'll take a look!

lforst pushed a commit that referenced this issue Apr 28, 2025
Resolves: #16075

We used to allow rewrapping of the root loader when we had a separate
Express adapter, where we could not determine the instrumentation order.
Now that we don't have it anymore, we can remove this. Still, can't
reproduce the original issue running e2e test apps under load. But it's
clear that's what caused it.
Copy link
Contributor

A PR closing this issue has just been released 🚀

This issue was referenced by PR #16136, which was included in the 9.15.0 release.

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

Successfully merging a pull request may close this issue.

5 participants