Skip to content

Commit

Permalink
Fix regression for environments without AbortController (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan authored and sindresorhus committed Apr 19, 2019
1 parent 7114ba3 commit a012fd3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ const timeout = (promise, ms, abortController) => new Promise((resolve, reject)
/* eslint-disable promise/prefer-await-to-then */
promise.then(resolve).catch(reject);
delay(ms).then(() => {
if (supportsAbortController) {
abortController.abort();
}

reject(new TimeoutError());
abortController.abort();
});
/* eslint-enable promise/prefer-await-to-then */
});
Expand Down

0 comments on commit a012fd3

Please sign in to comment.