Repository navigation
Closed as not planned
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? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.
@sentry/nextjs
SDK Version
7.37.2
Framework Version
NextJS 13.1.5
Link to Sentry event
No response
SDK Setup
Sentry.init({
dsn: DSN,
environment: ENVIRONMENT,
release: RELEASE,
tracesSampler: (samplingContext) => !!samplingContext.parentSampled || TRACES_SAMPLE_RATE,
integrations: [
// new Sentry.Replay({sessionSampleRate: 0, errorSampleRate: 1, maskAllInputs: true, useCompression: false}), // tried this
// new Sentry.Replay({sessionSampleRate: 0, errorSampleRate: 1, maskAllInputs: true}), // then tried this
// then tried without Replay
new Sentry.BrowserTracing({tracingOrigins: ["redacted"]}),
new Integrations.CaptureConsole({levels: ["error"]}),
new Integrations.ExtraErrorData({depth: 10}),
],
});Steps to Reproduce
- Update sentry packages from 7.37.1 to 7.37.2 and disabled replay compression
- Observe unexpected changes server memory utilization and server crashes
- Re-enable replay compression
- Observe memory changes still present after re-enabling replay compression (i.e. establish that compression enabled/disabled is not the cause)
- Remove replay's completely
- Observe memory changes still present without replays (i.e. establish that replays are not the cause)
Expected Result
No changes to memory utilization, no server crashes
Actual Result
After updating the packages, memory utilisation changed very dramatically with huge variations. On several occasions this brought down the instances (503s reported by users). Consistent across several clients, e.g.
Metadata
Metadata
Assignees
Labels
No labels



Activity
lforst commentedon Feb 17, 2023
Yo thanks for writing in, this seems rather serious. Right now I can't think of anything obvious that we released that might cause this. Can you share your
sentry.server.config.js?Also would you mind sharing a
$ git diffof your lockfile in the commit that caused this spike in your app? That would help us potentially isolate the problem.jdpst commentedon Feb 17, 2023
@lforst It's certainly not ideal. 😄 We've downgraded to 7.37.1 for now. For some additional context, we were upgrading because (1) Sentry is always reminding us to and (2) our Replay integration had recently stopped working, with errors like the one below that removing the compression fixed. We've been using Sentry, across our clients and backend for error monitoring and end-to-end tracing, for about a year without issues (well, prior to this one!).
sentry.server.config.js & sentry.edge.config.js
next.config.js
git diff
lforst commentedon Feb 20, 2023
My suspicion, for now, would be that the cause is related to the
tunnelRoutesetting innext.config.js. But I am really not sure...Do you know for what kind of event the
missing newline after header or payloaderror you get is showing up? Error, Transaction, or Replay?jdpst commentedon Feb 20, 2023
The error was for Replay events only. We were able to fix those errors by setting
useCompression: falsein the Replay settings.lforst commentedon Feb 20, 2023
Can you 100% confirm the only change you reverted was going from
7.37.1to7.37.2? The reason I am asking is because we didn't do any serverside changes: 7.37.1...7.37.2jdpst commentedon Feb 21, 2023
@lforst The only other changes made in that commit were to replace the
_errorpages with the updated version in the Sentry docs (i.e. we replaced the old boilerplate with the new boilerplate, which is as shown in the Sentry docs).As it so happens, dropping back to the prior version did not fix our issues. It looked like it did, but was a false positive. Ultimately, we saw erratic behaviour until finally reverting the changes to the
_errorpages. I'd initially assumed these changes couldn't be the culprit because they came straight from the docs.I haven't looked to see if there's a ticket for the
_errorpage issue, nor do I really understand what's actually happening there. I don't know why the changes were causing issues at all–we are using a compatible version of Sentry and NextJS (the latest version of both at the time).FWIW, we regularly see these errors, which are handled explicitly in the old boilerplate linked above but not in the new one. I have a suspicion that these errors were causing the new

_errorpage to blow up on the server, but I have no proof.Let me know if you have any thoughts on that, or whether to convert this or to create a new ticket and close this one.
lforst commentedon Feb 21, 2023
All good. I'll have a look at this. Thanks for the update!
lforst commentedon Feb 21, 2023
We have a few suspicions:
_error.jslook exactly like in the docs you shared?jdpst commentedon Feb 21, 2023
The only code we have that interacts explicitly with Sentry constructs is the below function to set a new idle transaction if one doesn't exist. We use this to instrument requests to our API.
All other usage is limited to
captureException(...)lforst commentedon Feb 21, 2023
Some more thoughts on this:
We might be running into some weird edge case here. Maybe in some event we trigger an intensive amount of computation? Could it be normalization of events?
Are you certain that your Sentry init really just consists of this on the server and edge routes?:
1 remaining item
lforst commentedon Feb 22, 2023
flushis simply waiting for outbound requests to Sentry to be completed. I'd be surprised if this is the culprit. Hosting provider shouldn't matter either.Due to the spiky nature of the graph I would put my bet on some large unexpected computation. Usually, the only heavy computation we do is to normalize/serialize events before sending them to sentry. It could very well be that
reqcontains a very large object in this case.We're investigating this.
lforst commentedon Feb 22, 2023
Can I ask? Do you sometimes have very large request bodies?
lforst commentedon Feb 22, 2023
And also, what is the memory limit of your machines?
jdpst commentedon Feb 22, 2023
We sometimes do have large somewhat large req payloads on certain SSR pages that needs some geo boundary data, but that is only on one client and this issue impacted all of our clients so I don't think it's relevant.
Each container runs with 1GB and 0.5 vCPU–fairly small instances.
lforst commentedon Feb 22, 2023
If you say "client" what do you mean exactly? The memory spikes are happening on the server right?
jdpst commentedon Feb 22, 2023
By client I mean dockerized NextJS application. Yes, the spikes are happening on the server running the docker container.
Apologies for the confusion–we also have a separate backend which all the NextJS apps make requests to. For simplicity we just refer an entire NextJS app (browser + edge + server) as a client (of our backend, which is running elsewhere).
lforst commentedon Feb 22, 2023
Aight. Thanks for the clarification! :)
I don't know how hard it is for you to verify any fixes so I am not sure if you can do the following in order to help us troubleshoot this. Could you try configuring the following integration like this in the edge and server inits?:
github-actions commentedon Mar 16, 2023
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 label it
Status: BacklogorStatus: In Progress, I will leave it alone ... forever!"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
tcarrio commentedon Apr 13, 2023
We are experiencing out-of-memory issues after updating to
@sentry/[email protected]. Seems like it could be related to this issue. Maybe we could reopen this since it's still a problem 🙂lforst commentedon Apr 14, 2023
@tcarrio may I ask you to open a separate issue with more details? This issue was about server-side memory leaks/spikes whereas yours seems to be in the browser (?).
chore(deps): Bump axios from 1.13.5 to 1.15.0 in /dev-packages/e2e-te…
chore(deps): Bump axios from 1.13.5 to 1.15.0 (#20180)