Skip to content

Commit fa0995e

Browse files
authored
Don't throw in background promise in withMontior
1 parent bc6725c commit fa0995e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

packages/core/src/exports.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,21 @@ export function withMonitor<T>(
174174
throw e;
175175
}
176176

177-
if (isThenable(maybePromiseResult)) {
178-
Promise.resolve(maybePromiseResult).then(
179-
() => {
180-
finishCheckIn('ok');
181-
},
182-
e => {
183-
finishCheckIn('error');
184-
throw e;
185-
},
186-
);
187-
} else {
177+
if (!isThenable(maybePromiseResult)) {
188178
finishCheckIn('ok');
179+
return maybePromiseResult;
189180
}
190181

191-
return maybePromiseResult;
182+
return maybePromiseResult.then(
183+
result => {
184+
finishCheckIn('ok');
185+
return result;
186+
},
187+
e => {
188+
finishCheckIn('error');
189+
throw e;
190+
},
191+
) as T;
192192
});
193193
}
194194

0 commit comments

Comments
 (0)