Skip to content

Commit

Permalink
Make sure cancellablePromise is not started if already aborted
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Jan 21, 2023
1 parent dcc4536 commit dd64299
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export function cancellablePromise<T>(
signal: AbortSignal,
promise: Promise<T>
) {
signal.throwIfAborted();

return Promise.race([
new Promise<never>((_resolve, reject) => {
signal.addEventListener("abort", () => {
Expand Down

0 comments on commit dd64299

Please sign in to comment.