Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e29a72

Browse filesBrowse files
fix(core): throw AggregateError after Promise.allSettled to preserve caller failure detection
Keep Promise.allSettled for resilience (all providers get a chance to flush), but throw AggregateError if any failed so callers can still detect failures. Co-authored-by: Eric Allam <ericallam@users.noreply.github.com>
1 parent c5b5fde commit 1e29a72
Copy full SHA for 1e29a72

1 file changed

+10Lines changed: 10 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/v3/otel/tracingSDK.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/v3/otel/tracingSDK.ts
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,16 @@ export class TracingSDK {
375375
this._meterProvider.forceFlush(),
376376
]);
377377
const providerNames = ["trace", "log", "meter"] as const;
378+
const errors: Error[] = [];
378379
results.forEach((result, index) => {
379380
if (result.status === "rejected") {
380381
console.error(`Failed to flush ${providerNames[index]} provider:`, result.reason);
382+
errors.push(result.reason instanceof Error ? result.reason : new Error(String(result.reason)));
381383
}
382384
});
385+
if (errors.length > 0) {
386+
throw new AggregateError(errors, "One or more providers failed to flush");
387+
}
383388
}
384389

385390
public async shutdown() {
@@ -389,11 +394,16 @@ export class TracingSDK {
389394
this._meterProvider.shutdown(),
390395
]);
391396
const providerNames = ["trace", "log", "meter"] as const;
397+
const errors: Error[] = [];
392398
results.forEach((result, index) => {
393399
if (result.status === "rejected") {
394400
console.error(`Failed to shutdown ${providerNames[index]} provider:`, result.reason);
401+
errors.push(result.reason instanceof Error ? result.reason : new Error(String(result.reason)));
395402
}
396403
});
404+
if (errors.length > 0) {
405+
throw new AggregateError(errors, "One or more providers failed to shutdown");
406+
}
397407
}
398408
}
399409

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.