-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix(test): replace Bun.sleep with utimes in dsn-cache mtime tests #612
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
Changes from all commits
9d185e3
1dbdddb
dcca225
c4113ab
3047930
3e3cdb7
1b360cf
8f2e701
c2c9655
2b3af8d
976b794
9cb088b
b5fb10a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,7 +275,7 @@ const LIBRARY_EXCLUDED_INTEGRATIONS = new Set([ | |
| ...EXCLUDED_INTEGRATIONS, | ||
| "OnUncaughtException", // process.on('uncaughtException') | ||
| "OnUnhandledRejection", // process.on('unhandledRejection') | ||
| "ProcessSession", // process.on('beforeExit') | ||
| "ProcessSession", // process.on('beforeExit') — anonymous handler, no cleanup | ||
| "Http", // diagnostics_channel + trace headers | ||
| "NodeFetch", // diagnostics_channel + trace headers | ||
| "FunctionToString", // wraps Function.prototype.toString | ||
|
|
@@ -355,6 +355,13 @@ export function initSentry( | |
| const libraryMode = options?.libraryMode ?? false; | ||
| const environment = getEnv().NODE_ENV ?? "development"; | ||
|
|
||
| // Close the previous client to clean up its internal timers and beforeExit | ||
| // handlers (client report flusher interval, log flush listener). Without | ||
| // this, re-initializing the SDK (e.g., in tests) leaks setInterval handles | ||
| // that keep the event loop alive and prevent the process from exiting. | ||
| // close(0) removes listeners synchronously; we don't need to await the flush. | ||
| Sentry.getClient()?.close(0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Telemetry init closes host Sentry clientHigh Severity
|
||
|
|
||
| const client = Sentry.init({ | ||
| dsn: SENTRY_CLI_DSN, | ||
| enabled, | ||
|
|
@@ -374,10 +381,12 @@ export function initSentry( | |
| }, | ||
| environment, | ||
| // Enable Sentry structured logs for non-exception telemetry (e.g., unexpected input warnings). | ||
| // Disabled in library mode — logs use timers/beforeExit that pollute the host process. | ||
| enableLogs: !libraryMode, | ||
| // Disable client reports in library mode — they use timers/beforeExit. | ||
| ...(libraryMode && { sendClientReports: false }), | ||
| // Disabled when telemetry is off or in library mode — the SDK registers | ||
| // beforeExit handlers for log flushing that keep the event loop alive. | ||
| enableLogs: enabled && !libraryMode, | ||
| // Disable client reports when telemetry is off or in library mode — the SDK | ||
| // registers a setInterval + beforeExit handler that keep the event loop alive. | ||
| ...((libraryMode || !enabled) && { sendClientReports: false }), | ||
| // Sample all events for CLI telemetry (low volume) | ||
| tracesSampleRate: 1, | ||
| sampleRate: 1, | ||
|
|
@@ -405,6 +414,12 @@ export function initSentry( | |
| }, | ||
| }); | ||
|
|
||
| // Always remove our own previous handler on re-init. | ||
| if (currentBeforeExitHandler) { | ||
| process.removeListener("beforeExit", currentBeforeExitHandler); | ||
| currentBeforeExitHandler = null; | ||
| } | ||
|
|
||
| if (client?.getOptions().enabled) { | ||
| const isBun = typeof process.versions.bun !== "undefined"; | ||
| const runtime = isBun ? "bun" : "node"; | ||
|
|
@@ -442,13 +457,7 @@ export function initSentry( | |
| // Skipped in library mode — the host owns the process lifecycle. | ||
| // The library entry point calls client.flush() manually after completion. | ||
| // | ||
| // Replace previous handler on re-init (e.g., auto-login retry calls | ||
| // withTelemetry → initSentry twice) to avoid duplicate handlers with | ||
| // independent re-entry guards and stale client references. | ||
| if (!libraryMode) { | ||
| if (currentBeforeExitHandler) { | ||
| process.removeListener("beforeExit", currentBeforeExitHandler); | ||
| } | ||
| currentBeforeExitHandler = createBeforeExitHandler(client); | ||
| process.on("beforeExit", currentBeforeExitHandler); | ||
| } | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.