@@ -55,7 +55,8 @@ export function trace<T>(
55
55
}
56
56
57
57
if ( isThenable ( maybePromiseResult ) ) {
58
- maybePromiseResult . then (
58
+ // @ts -expect-error - the isThenable check returns the "wrong" type here
59
+ return maybePromiseResult . then (
59
60
res => {
60
61
finishAndSetSpan ( ) ;
61
62
afterFinish ( ) ;
@@ -69,11 +70,10 @@ export function trace<T>(
69
70
throw e ;
70
71
} ,
71
72
) ;
72
- } else {
73
- finishAndSetSpan ( ) ;
74
- afterFinish ( ) ;
75
73
}
76
74
75
+ finishAndSetSpan ( ) ;
76
+ afterFinish ( ) ;
77
77
return maybePromiseResult ;
78
78
}
79
79
@@ -91,7 +91,7 @@ export function trace<T>(
91
91
export function startSpan < T > ( context : TransactionContext , callback : ( span : Span | undefined ) => T ) : T {
92
92
const ctx = normalizeContext ( context ) ;
93
93
94
- // @ts -expect-error - wtf
94
+ // @ts -expect-error - isThenable returns the wrong type
95
95
return withScope ( scope => {
96
96
const hub = getCurrentHub ( ) ;
97
97
const parentSpan = scope . getSpan ( ) ;
@@ -124,10 +124,10 @@ export function startSpan<T>(context: TransactionContext, callback: (span: Span
124
124
throw e ;
125
125
} ,
126
126
) ;
127
- } else {
128
- finishAndSetSpan ( ) ;
129
- return maybePromiseResult ;
130
127
}
128
+
129
+ finishAndSetSpan ( ) ;
130
+ return maybePromiseResult ;
131
131
} ) ;
132
132
}
133
133
@@ -153,6 +153,7 @@ export function startSpanManual<T>(
153
153
) : T {
154
154
const ctx = normalizeContext ( context ) ;
155
155
156
+ // @ts -expect-error - isThenable returns the wrong type
156
157
return withScope ( scope => {
157
158
const hub = getCurrentHub ( ) ;
158
159
const parentSpan = scope . getSpan ( ) ;
@@ -173,7 +174,7 @@ export function startSpanManual<T>(
173
174
}
174
175
175
176
if ( isThenable ( maybePromiseResult ) ) {
176
- maybePromiseResult . then (
177
+ return maybePromiseResult . then (
177
178
res => res ,
178
179
e => {
179
180
activeSpan && activeSpan . setStatus ( 'internal_error' ) ;
0 commit comments