You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{EventHint,NodeClient,Scope,defaultStackParser,getDefaultIntegrations,makeNodeTransport,}from"@sentry/node";import{Env}from"./config";import{NodeEnv}from"./consts";constTraycerScope: Scope=newScope();exportfunctioninitSentry(){// filter integrations that use the global variableconstintegrations=getDefaultIntegrations({}).filter((defaultIntegration)=>{return!["OnUnhandledRejection","OnUncaughtException","CaptureConsole",].includes(defaultIntegration.name);},);constclient=newNodeClient({dsn: "DSN",integrations: integrations,beforeSend(event){for(constexofevent?.exception?.values??[]){for(constframeofex.stacktrace?.frames??[]){if(frame.filename?.includes(Env.extensionName)){returnevent;}}}returnnull;},tracesSampleRate: 0.2,profilesSampleRate: 1.0,sampleRate: 1.0,attachStacktrace: true,environment: Env.nodeEnv,includeLocalVariables: true,serverName: "traycer-vscode",transport: makeNodeTransport,stackParser: defaultStackParser,});TraycerScope.setTag("extention",Env.extensionName);TraycerScope.setClient(client);client.init();}exportfunctioncaptureException(ex: unknown,hint?: EventHint|undefined,): unknown{if(Env.nodeEnv===NodeEnv.Production){TraycerScope.captureException(ex,hint);}returnex;}exportfunctionsetScopeTag(key: string,value: string){TraycerScope.setTag(key,value);}exportasyncfunctionclose(){awaitTraycerScope.getClient()?.close(2000);}
Steps to Reproduce
Build VS Code extension having Sentry configured using esbuild
Install the extension
Observe the CPU usage
Expected Result
It should work normally without any additional memory / cpu load.
Actual Result
When the extension (having sentry) is installed in VS Code, it blocks the event loop in the Extension Host, causing high CPU and memory usage that ultimately results in an Extension Host crash.
A CPU profile indicates that the package require-in-the-middle (brought in by @opentelemetry/instrumentation under @sentry/node) is loaded as soon as the extension activates.
This package seems to block the event loop, rendering the Extension Host unresponsive.
After removing Sentry from the extension’s dependencies, the Extension Host resumed normal performance without CPU or memory overload.
@andreiborza Thanks for sharing the information. We will try @sentry/browser. I think we used @sentry/node initially as we were using it for metrics which was not supported with browser SDK maybe.
Also, I feel the issue which we faced could happen in a non vs code extension based application as well because we could see it blocking the CPU for a long period.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.45.0
Framework Version
Node 20.18.1
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
Expected Result
It should work normally without any additional memory / cpu load.
Actual Result
When the extension (having sentry) is installed in VS Code, it blocks the event loop in the Extension Host, causing high CPU and memory usage that ultimately results in an Extension Host crash.
require-in-the-middle
(brought in by@opentelemetry/instrumentation
under@sentry/node
) is loaded as soon as the extension activates.CPU-20241224T083236.459Z.cpuprofile.txt
The text was updated successfully, but these errors were encountered: