Skip to content

Commit 83592c8

Browse files
committed
fix other trace functions
1 parent 722683d commit 83592c8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/core/src/tracing/trace.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export function trace<T>(
5555
}
5656

5757
if (isThenable(maybePromiseResult)) {
58-
maybePromiseResult.then(
58+
// @ts-expect-error - the isThenable check returns the "wrong" type here
59+
return maybePromiseResult.then(
5960
res => {
6061
finishAndSetSpan();
6162
afterFinish();
@@ -69,11 +70,10 @@ export function trace<T>(
6970
throw e;
7071
},
7172
);
72-
} else {
73-
finishAndSetSpan();
74-
afterFinish();
7573
}
7674

75+
finishAndSetSpan();
76+
afterFinish();
7777
return maybePromiseResult;
7878
}
7979

@@ -91,7 +91,7 @@ export function trace<T>(
9191
export function startSpan<T>(context: TransactionContext, callback: (span: Span | undefined) => T): T {
9292
const ctx = normalizeContext(context);
9393

94-
// @ts-expect-error - wtf
94+
// @ts-expect-error - isThenable returns the wrong type
9595
return withScope(scope => {
9696
const hub = getCurrentHub();
9797
const parentSpan = scope.getSpan();
@@ -124,10 +124,10 @@ export function startSpan<T>(context: TransactionContext, callback: (span: Span
124124
throw e;
125125
},
126126
);
127-
} else {
128-
finishAndSetSpan();
129-
return maybePromiseResult;
130127
}
128+
129+
finishAndSetSpan();
130+
return maybePromiseResult;
131131
});
132132
}
133133

@@ -153,6 +153,7 @@ export function startSpanManual<T>(
153153
): T {
154154
const ctx = normalizeContext(context);
155155

156+
// @ts-expect-error - isThenable returns the wrong type
156157
return withScope(scope => {
157158
const hub = getCurrentHub();
158159
const parentSpan = scope.getSpan();
@@ -173,7 +174,7 @@ export function startSpanManual<T>(
173174
}
174175

175176
if (isThenable(maybePromiseResult)) {
176-
maybePromiseResult.then(
177+
return maybePromiseResult.then(
177178
res => res,
178179
e => {
179180
activeSpan && activeSpan.setStatus('internal_error');

0 commit comments

Comments
 (0)