diff --git a/.changeset/plenty-snails-return.md b/.changeset/plenty-snails-return.md new file mode 100644 index 00000000000..6a4f3d0b607 --- /dev/null +++ b/.changeset/plenty-snails-return.md @@ -0,0 +1,5 @@ +--- +'@shopify/cli-kit': patch +--- + +[internal] suppress console errors when pushing metrics diff --git a/packages/cli-kit/src/private/node/otel-metrics.ts b/packages/cli-kit/src/private/node/otel-metrics.ts index 9f0dd3a3f56..5e0545503a9 100644 --- a/packages/cli-kit/src/private/node/otel-metrics.ts +++ b/packages/cli-kit/src/private/node/otel-metrics.ts @@ -5,7 +5,7 @@ import { DefaultOtelServiceOptions, } from '../../public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js' import {isUnitTest, opentelemetryDomain} from '../../public/node/context/local.js' -import {ValueType} from '@opentelemetry/api' +import {ValueType, diag} from '@opentelemetry/api' type MetricRecorder = | 'console' @@ -150,6 +150,9 @@ function globalOtelService(options: CreateMetricRecorderOptions): OtelService { env: undefined, otelEndpoint: `${opentelemetryDomain()}/v1/metrics`, }) + // Suppress OTEL diagnostic output — internal export errors (e.g. retryable failures) + // should never appear in user-facing CLI output. + diag.disable() } return _otelService } diff --git a/packages/cli-kit/src/public/node/vendor/otel-js/utils/throttle.ts b/packages/cli-kit/src/public/node/vendor/otel-js/utils/throttle.ts index 3880ea298be..2c1adaa4dec 100644 --- a/packages/cli-kit/src/public/node/vendor/otel-js/utils/throttle.ts +++ b/packages/cli-kit/src/public/node/vendor/otel-js/utils/throttle.ts @@ -21,6 +21,12 @@ export function throttle any>( timeout = null if (lastArgs) { result = func.apply(context, lastArgs) + // If the throttled function returns a promise, swallow rejections to + // prevent unhandled promise rejections (the caller already .catch()'d + // the leading-edge invocation and has no reference to trailing calls). + if (result && typeof (result as any).catch === 'function') { + (result as any).catch(() => {}) + } } context = null lastArgs = null