From 3171892198d6a3dc70e50add8cafda7d4cb691bf Mon Sep 17 00:00:00 2001 From: A Ibrahim Date: Thu, 19 Nov 2026 10:07:41 -0600 Subject: [PATCH] fix(cli): stop Sentry warning on every run of the Bun binary Telemetry kept all Sentry default integrations except a denylist, which included web framework integrations. Under Bun they can't be injected and Sentry warns "No diagnostics-channel injection detected" on every command. Switch to an allowlist of the integrations error reporting needs. Assisted-by: Claude Opus 5.5 via Claude Code Co-Authored-By: Claude Opus 5.5 --- .changeset/cli-sentry-bun-warning.md | 5 ++ packages/cli/src/utils/telemetry.ts | 34 ++++++++------ packages/cli/test/utils/telemetry.test.ts | 57 ++++++++++++----------- 3 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 .changeset/cli-sentry-bun-warning.md diff --git a/.changeset/cli-sentry-bun-warning.md b/.changeset/cli-sentry-bun-warning.md new file mode 100644 index 00000000..3874d864 --- /dev/null +++ b/.changeset/cli-sentry-bun-warning.md @@ -0,0 +1,5 @@ +--- +"@tigrisdata/cli": patch +--- + +Stop the standalone binary from printing a Sentry "No diagnostics-channel injection detected" warning on every command. Telemetry now enables only the Sentry integrations error reporting needs, instead of every default minus a denylist. diff --git a/packages/cli/src/utils/telemetry.ts b/packages/cli/src/utils/telemetry.ts index 8055592e..ce8f9cd0 100644 --- a/packages/cli/src/utils/telemetry.ts +++ b/packages/cli/src/utils/telemetry.ts @@ -77,7 +77,12 @@ export function invocationCommand(argv: string[]): string | undefined { return first && !first.startsWith('-') ? first : undefined; } -// Sentry default integrations we deliberately drop: +// The Sentry default integrations we keep. An allowlist, because each SDK +// release adds defaults for servers, databases and AI libraries that a CLI +// never loads, and some of them print a warning on every run in the Bun +// binary ("No diagnostics-channel injection detected"). +// +// Defaults we deliberately leave out, besides those: // - OnUncaughtException / OnUnhandledRejection: we own process exit ourselves. // - LocalVariables(Async): captures local variable values (e.g. credentials) // into stack frames, which beforeSend does not scrub. @@ -91,23 +96,23 @@ export function invocationCommand(argv: string[]): string | undefined { // processed when the process ended. Without them capture is synchronous; the // OS release is set in configure() instead, and source lines of the minified // bundle say little. -export const DISABLED_INTEGRATIONS: ReadonlySet = new Set([ - 'OnUncaughtException', - 'OnUnhandledRejection', - 'LocalVariables', - 'LocalVariablesAsync', - 'Console', - 'ChildProcess', - 'ProcessSession', - 'Context', - 'ContextLines', +export const ENABLED_INTEGRATIONS: ReadonlySet = new Set([ + 'EventFilters', + 'FunctionToString', + 'LinkedErrors', + 'Dedupe', + 'NodeSystemError', + 'Http', + 'NodeFetch', + 'WorkerThreads', + 'Modules', ]); -/** The SDK's default integrations minus DISABLED_INTEGRATIONS. */ +/** The SDK's default integrations that are in ENABLED_INTEGRATIONS. */ export function selectIntegrations( defaults: T[] ): T[] { - return defaults.filter((i) => !DISABLED_INTEGRATIONS.has(i.name)); + return defaults.filter((i) => ENABLED_INTEGRATIONS.has(i.name)); } /** @@ -235,8 +240,7 @@ function configure(sdk: SentryModule, dsn: string): void { // Error reporting only — no performance tracing. tracesSampleRate: 0, dataCollection: DATA_COLLECTION, - // Drop integrations that fight our exit handling, delay capture, or - // capture user data we don't scrub. See DISABLED_INTEGRATIONS. + // Only the integrations error reporting needs. See ENABLED_INTEGRATIONS. integrations: selectIntegrations, beforeSend, // Delivered by the detached sender; see makeQueuedTransport. diff --git a/packages/cli/test/utils/telemetry.test.ts b/packages/cli/test/utils/telemetry.test.ts index 45fe73ac..8e515abd 100644 --- a/packages/cli/test/utils/telemetry.test.ts +++ b/packages/cli/test/utils/telemetry.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'; import { beforeSend, - DISABLED_INTEGRATIONS, + ENABLED_INTEGRATIONS, invocationCommand, redactSecrets, scrubArgv, @@ -11,41 +11,46 @@ import { } from '../../src/utils/telemetry.js'; describe('selectIntegrations', () => { - // The filter works by name, so a rename upstream would silently stop - // dropping an integration. Pin the ones that carry user data. - const guarded = [ - 'OnUncaughtException', - 'OnUnhandledRejection', - 'LocalVariablesAsync', - 'Console', - 'ChildProcess', - // Not user data, but they delay exit or make capture asynchronous, which - // the detached sender depends on not happening. - 'ProcessSession', - 'Context', - 'ContextLines', - ]; + const kept = () => + selectIntegrations(getDefaultIntegrations({})).map((i) => i.name); - it('still finds every guarded integration among the defaults', () => { + // The filter works by name, so a rename upstream would silently drop an + // integration we rely on. + it('still finds every enabled integration among the defaults', () => { const names = getDefaultIntegrations({}).map((i) => i.name); - for (const name of guarded) { + for (const name of ENABLED_INTEGRATIONS) { expect( names, `${name} is no longer a default integration name` ).toContain(name); } + expect(kept()).toEqual( + names.filter((name) => ENABLED_INTEGRATIONS.has(name)) + ); }); - it('drops them and keeps the rest', () => { - const defaults = getDefaultIntegrations({}); - const kept = selectIntegrations(defaults).map((i) => i.name); - for (const name of DISABLED_INTEGRATIONS) { - expect(kept).not.toContain(name); + it('drops integrations that carry user data or delay exit', () => { + for (const name of [ + 'OnUncaughtException', + 'OnUnhandledRejection', + 'LocalVariables', + 'LocalVariablesAsync', + 'Console', + 'ChildProcess', + 'ProcessSession', + 'Context', + 'ContextLines', + ]) { + expect(kept()).not.toContain(name); + } + }); + + // These instrument libraries through diagnostics channels, which the Bun + // binary cannot inject, so Sentry warns on every run when they are on. + it('drops server framework integrations', () => { + for (const name of ['Express', 'Fastify', 'Hapi', 'Hono', 'Koa', 'Nitro']) { + expect(kept()).not.toContain(name); } - expect(kept.length).toBe( - defaults.filter((i) => !DISABLED_INTEGRATIONS.has(i.name)).length - ); - expect(kept).toContain('LinkedErrors'); }); });