Skip to content

Commit 1cd0480

Browse files
committed
fix(core): Rethrow caught promise rejections in startSpan, startSpanManual, trace
1 parent 5d16aae commit 1cd0480

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/core/src/tracing/trace.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ export function trace<T>(
5555
}
5656

5757
if (isThenable(maybePromiseResult)) {
58-
Promise.resolve(maybePromiseResult).then(
59-
() => {
58+
maybePromiseResult.then(
59+
res => {
6060
finishAndSetSpan();
6161
afterFinish();
62+
return res;
6263
},
6364
e => {
6465
activeSpan && activeSpan.setStatus('internal_error');
6566
onError(e, activeSpan);
6667
finishAndSetSpan();
6768
afterFinish();
69+
throw e;
6870
},
6971
);
7072
} else {
@@ -87,6 +89,7 @@ export function trace<T>(
8789
* and the `span` returned from the callback will be undefined.
8890
*/
8991
export function startSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T {
92+
console.log('START SPAN 2');
9093
const ctx = normalizeContext(context);
9194

9295
return withScope(scope => {

0 commit comments

Comments
 (0)