Skip to content

Commit 62088dc

Browse files
committed
suppress otel errors in console
1 parent c1334f6 commit 62088dc

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.changeset/plenty-snails-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-kit': patch
3+
---
4+
5+
[internal] suppress console errors when pushing metrics

packages/cli-kit/src/private/node/otel-metrics.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DefaultOtelServiceOptions,
66
} from '../../public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js'
77
import {isUnitTest, opentelemetryDomain} from '../../public/node/context/local.js'
8-
import {ValueType} from '@opentelemetry/api'
8+
import {ValueType, diag} from '@opentelemetry/api'
99

1010
type MetricRecorder =
1111
| 'console'
@@ -150,6 +150,9 @@ function globalOtelService(options: CreateMetricRecorderOptions): OtelService {
150150
env: undefined,
151151
otelEndpoint: `${opentelemetryDomain()}/v1/metrics`,
152152
})
153+
// Suppress OTEL diagnostic output — internal export errors (e.g. retryable failures)
154+
// should never appear in user-facing CLI output.
155+
diag.disable()
153156
}
154157
return _otelService
155158
}

packages/cli-kit/src/public/node/vendor/otel-js/utils/throttle.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export function throttle<T extends (...args: any) => any>(
2121
timeout = null
2222
if (lastArgs) {
2323
result = func.apply(context, lastArgs)
24+
// If the throttled function returns a promise, swallow rejections to
25+
// prevent unhandled promise rejections (the caller already .catch()'d
26+
// the leading-edge invocation and has no reference to trailing calls).
27+
if (result && typeof (result as any).catch === 'function') {
28+
;(result as any).catch(() => {})
29+
}
2430
}
2531
context = null
2632
lastArgs = null

0 commit comments

Comments
 (0)