sentry-javascript-bundler-plugins: sentry-vite-plugin cause javascript out of memory
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
1.configed project using npx @sentry/wizard@latest -i sourcemaps `import { defineConfig } from “vite”; import { sentryVitePlugin } from “@sentry/vite-plugin”;
export default defineConfig({ build: { sourcemap: true, // Source map generation must be turned on }, plugins: [ // Put the Sentry vite plugin after all other plugins sentryVitePlugin({ org: “", project: "”, authToken: process.env.SENTRY_AUTH_TOKEN, }), ], });` 2.run npm run build 3.got error /usr/local/bin/npm run build
myproject@0.3.7 build vite build --mode production
[sentry-vite-plugin] Info: Using environment variables configured in “.env.sentry-build-plugin”.
build.terserOptions is specified but build.minify is not set to use Terser. Note Vite now defaults to use esbuild for minification. If you still prefer Terser, set build.minify to “terser”.
vite v4.3.9 building for production…
[sentry-vite-plugin] Info: Sending error and performance telemetry data to Sentry. To disable telemetry, set options.telemetry to false.
transforming (6) src/router/guard/index.tsBrowserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: https://github.com/browserslist/update-db#readme
✓ 4296 modules transformed.
rendering chunks (39)…
<— Last few GCs —>
[3575:0x158008000] 37526 ms: Mark-Compact 4049.0 (4137.9) -> 4047.4 (4137.9) MB, 836.71 / 0.00 ms (average mu = 0.218, current mu = 0.037) allocation failure; scavenge might not succeed [3575:0x158008000] 39532 ms: Mark-Compact 4055.3 (4137.9) -> 4054.6 (4167.6) MB, 1995.46 / 0.00 ms (average mu = 0.102, current mu = 0.005) allocation failure; scavenge might not succeed
<— JS stacktrace —>
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 1: 0x1028ca114 node::Abort() [/usr/local/bin/node] 2: 0x1028ca2fc node::ModifyCodeGenerationFromStrings(v8::Localv8::Context, v8::Localv8::Value, bool) [/usr/local/bin/node] 3: 0x102a51048 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/bin/node] 4: 0x102c2582c v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/usr/local/bin/node] 5: 0x102c24308 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node] 6: 0x102c1ab20 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node] 7: 0x102c1b380 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node] 8: 0x102c00384 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node] 9: 0x102fe7d94 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node] 10: 0x103344c44 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node] 11: 0x10901405c 12: 0x109a9123c 13: 0x1088a7ba8 14: 0x109bca03c 15: 0x109b09258 16: 0x108de33cc 17: 0x10879b734 18: 0x1033a0fb8 Builtins_PromiseFulfillReactionJob [/usr/local/bin/node] 19: 0x1032e2b94 Builtins_RunMicrotasks [/usr/local/bin/node] 20: 0x1032ba3f4 Builtins_JSRunMicrotasksEntry [/usr/local/bin/node] 21: 0x102b92c94 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/usr/local/bin/node] 22: 0x102b93180 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/usr/local/bin/node] 23: 0x102b9335c v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/usr/local/bin/node] 24: 0x102bba418 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/usr/local/bin/node] 25: 0x102bbabb4 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/usr/local/bin/node] 26: 0x102abec4c v8::internal::MaybeHandlev8::internal::Object v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::FunctionTemplateInfo, v8::internal::Handlev8::internal::Object, unsigned long*, int) [/usr/local/bin/node] 27: 0x102abe344 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node] 28: 0x103344b24 Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit [/usr/local/bin/node] 29: 0x10861d848 30: 0x1032ba50c Builtins_JSEntryTrampoline [/usr/local/bin/node] 31: 0x1032ba1f4 Builtins_JSEntry [/usr/local/bin/node] 32: 0x102b92cbc v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/usr/local/bin/node] 33: 0x102b92108 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object, int, v8::internal::Handlev8::internal::Object) [/usr/local/bin/node] 34: 0x102a6c9d4 v8::Function::Call(v8::Localv8::Context, v8::Localv8::Value, int, v8::Localv8::Value) [/usr/local/bin/node] 35: 0x1027fcd3c node::InternalCallbackScope::Close() [/usr/local/bin/node] 36: 0x1027fd01c node::InternalMakeCallback(node::Environment*, v8::Localv8::Object, v8::Localv8::Object, v8::Localv8::Function, int, v8::Localv8::Value, node::async_context) [/usr/local/bin/node] 37: 0x10281348c node::AsyncWrap::MakeCallback(v8::Localv8::Function, int, v8::Localv8::Value) [/usr/local/bin/node] 38: 0x1029971a4 node::StreamBase::CallJSOnreadMethod(long, v8::Localv8::ArrayBuffer, unsigned long, node::StreamBase::StreamBaseJSChecks) [/usr/local/bin/node] 39: 0x102998838 node::EmitToJSStreamListener::OnStreamRead(long, uv_buf_t const&) [/usr/local/bin/node] 40: 0x10299cb2c node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [/usr/local/bin/node] 41: 0x10299d2b0 node::LibuvStreamWrap::ReadStart():😒_1::__invoke(uv_stream_s*, long, uv_buf_t const*) [/usr/local/bin/node] 42: 0x1032a6f70 uv__stream_io [/usr/local/bin/node] 43: 0x1032ae874 uv__io_poll [/usr/local/bin/node] 44: 0x10329cd60 uv_run [/usr/local/bin/node] 45: 0x1027fd754 node::SpinEventLoopInternal(node::Environment*) [/usr/local/bin/node] 46: 0x10290d138 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/usr/local/bin/node] 47: 0x10290ced4 node::NodeMainInstance::Run() [/usr/local/bin/node] 48: 0x10289560c node::Start(int, char**) [/usr/local/bin/node] 49: 0x187ce10e0 start [/usr/lib/dyld]
exit code 134 (interrupted by signal 6: SIGABRT)
Expected Result
build success
Actual Result
if i comment out sentryVitePlugin and it also can build complete
Product Area
Issues - Source Maps
Link
https://tankmiles-dei.sentry.io/releases/
DSN
https://c030969be018368bb25c4c054b4204d9@o4505038212694016.ingest.sentry.io/4506313168060416
Version
No response
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 15
- Comments: 43 (14 by maintainers)
@smakhtin Big. Thank you! We will take a look!
@GreenbowAllan We have no reason to believe it is
@sentry/vite-plugincausing the oom issues but rather vite itself (or other plugins) consuming a lot of memory when generating or emitting source maps.If you want to contribute to this you could share a heap profile of your builds when they oom.
Okay, I’m gonna go ahead and close this issue. For anybody running into this, it seems like the best solution is to upgrade
viteto version4.4.9and@sentry/vite-pluginto version2.16.1. Both packages introduced performance/memory consumption improvements in those versions. Feel free to ping me here if you have any new findings (in case the issue persists)!Hello @getsentry team and fellow developers,
I’ve been following this thread with interest, as I am encountering a similar issue with the Sentry Vite plugin in a Nuxt 3 project. Specifically, enabling the plugin with source map generation leads to an OOM error in our Jenkins/Docker build pipeline, significantly affecting our CI/CD processes.
Has there been any progress or potential workarounds identified since the last update? I’ve noticed that increasing the memory allocation for Node.js has been a temporary fix for some, but it’s not a viable long-term solution for us due to the constraints of our build environment.
Additionally, if there’s any specific information or debugging data that could help in diagnosing this issue further, please let me know. I’m eager to contribute to finding a solution that helps not just our project but others facing similar challenges.
Thank you for your efforts and any guidance you can provide.
Here is the reproducible example - https://github.com/sovereign-nature/deep/blob/main/apps/verification-portal/vite.config.ts. Just uncomment sentry lines and the build process will stuck after source maps upload.
I do not have a reproducible example at this time but I can confirm that the issue only occurs when we add the
@sentry/vite-pluginto our build.The build succeeds when generating source maps without the sentry plugin. We tried using a custom plugin to exclude node_modules from sourcemaps; again the build succeeds w/o @sentry/vite-plugin but fails due to OOM error with the sentry plugin. Our build is only 87MB and we allocate 4GB for the build node process and still do not have enough memory when the sentry plugin is included in the build.
I’m starting to read through the plugin source code and will update if I find anything suspicious.
Update:
Increasing --max-old-space-size by 75% to 7GB still fails when the @sentry/vite-plugin is included in the build
Hi all, we just released version 2.16.1 of the package. Can you try whether upgrading fixes the issue for you? (🤞)
the issue is usually because of sourcemaps for large files for me issue was solved by manually creating chunks and making the main vendor file smaller
Experiencing the same problem if somebody found a solution…
Turns out it was the vite build that was failing with OOM when generating the source maps even if I removed the Sentry plugin from the equation, thus not related to this project. I excluded “node_modules” and everything went fine.
For our CI it was also fixed by updating @sentry/vite-plugin from 2.16.0 to 2.16.1
After producing (seemingly) no useful output with the profiler I branched out to maybe produce some useful information and alas:
So TL;DR: Not sentry-vite-plugin’s fault after all?
As far as I know - no. Vendor bundle isolation helped me, but caused other bugs with caching, so now I just disabled source maps. Very annoying bug.
I think i can confirm it that bundle size was causing this error. I isolated vendor bundle and everything works again.
I just run into it as well when trying to setup vite plugin using sentry wizzard.
sourcemap enabled and
sentryVitePluginsourcemap enabled, without
sentryVitePluginIncreasing max memory used to 8GB worked.
We do have relatively large code base, so not quite sure , but based on monitoring, it peak above 5GB before finishing.
What is interesting is that when enabled, the transformed module count increased from
5594 modules transformed.to5595 modules transformed.