fix(core): use Promise.allSettled in TracingSDK flush/shutdown

Switch TracingSDK.flush() and shutdown() from Promise.all to
Promise.allSettled to prevent one provider's rejection from
abandoning the other providers' in-flight exports.

This fixes an issue where user-emitted trace data (logger.info
calls, child spans) could be silently dropped on shutdown when
any provider fails to flush, particularly affecting self-hosted
deployments with processKeepAliveEnabled: false.

Fixes #3556

Co-authored-by: Eric Allam <ericallam@users.noreply.github.com>
This commit is contained in:
claude[bot]
2026-05-12 13:47:24 +00:00
parent 41a486ea7e
commit c5b5fde24d
2 changed files with 19 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---
Fixed TracingSDK.flush() and shutdown() to use Promise.allSettled instead of Promise.all, preventing one provider's rejection from abandoning the other providers' in-flight exports. This fixes an issue where user-emitted trace data (logger.info calls, child spans) could be silently dropped on shutdown when any provider fails to flush.
+14 -2
View File
@@ -369,19 +369,31 @@ export class TracingSDK {
}
public async flush() {
await Promise.all([
const results = await Promise.allSettled([
this._traceProvider.forceFlush(),
this._logProvider.forceFlush(),
this._meterProvider.forceFlush(),
]);
const providerNames = ["trace", "log", "meter"] as const;
results.forEach((result, index) => {
if (result.status === "rejected") {
console.error(`Failed to flush ${providerNames[index]} provider:`, result.reason);
}
});
}
public async shutdown() {
await Promise.all([
const results = await Promise.allSettled([
this._traceProvider.shutdown(),
this._logProvider.shutdown(),
this._meterProvider.shutdown(),
]);
const providerNames = ["trace", "log", "meter"] as const;
results.forEach((result, index) => {
if (result.status === "rejected") {
console.error(`Failed to shutdown ${providerNames[index]} provider:`, result.reason);
}
});
}
}