From 6e1543a11920f65c94910191a09063f04f3c18c5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 03:11:18 +0000 Subject: [PATCH] fix(cli): use named helper for sentry rejections Co-Authored-By: mantra --- packages/cli/src/lib/sentry.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/lib/sentry.ts b/packages/cli/src/lib/sentry.ts index 8602189c4..4de9eb2a4 100644 --- a/packages/cli/src/lib/sentry.ts +++ b/packages/cli/src/lib/sentry.ts @@ -29,6 +29,11 @@ let sentryModule: typeof import("@sentry/node") | undefined; let initPromise: Promise | undefined; let capturePromise: Promise | undefined; +function ignoreUnhandledRejection(promise: Promise): void { + // Keep this local to avoid eagerly importing the heavy shared promises module; telemetry failures must not affect CLI output or exit codes. + promise.catch(() => {}); +} + async function loadSentry(): Promise { sentryModule ??= await import("@sentry/node"); return sentryModule; @@ -71,13 +76,10 @@ export function initSentry(): void { const Sentry = await loadSentry(); Sentry.captureException(error, { extra: { location }, level }); await Sentry.flush(2000); - })().catch(() => { - // Optional telemetry failures must not create unhandled rejections or affect CLI errors. - }); - })) - .catch(() => { - // Optional telemetry registration failures must not create unhandled rejections or affect CLI errors. - }); + })(); + ignoreUnhandledRejection(capturePromise); + })); + ignoreUnhandledRejection(registrationPromise); } export async function captureFatalError(location: string, error: unknown, timeoutMs = 2000): Promise {