summaryrefslogtreecommitdiff
path: root/lib/timers
diff options
context:
space:
mode:
authorBenjamin Gruenbaum <benjamingr@gmail.com>2020-11-29 20:01:24 +0200
committerNode.js GitHub Bot <github-bot@iojs.org>2020-12-01 18:51:05 +0000
commit1ed72f67f5ea82b36b8589e447619e98c004fa12 (patch)
tree1131b488d731d60fd8a67ea44a0381fdcc199398 /lib/timers
parent780fcb42496f9a1c182597dda92d12f0c7a0c7a6 (diff)
downloadnode-new-1ed72f67f5ea82b36b8589e447619e98c004fa12.tar.gz
timers: reject with AbortError on cancellation
PR-URL: https://github.com/nodejs/node/pull/36317 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
Diffstat (limited to 'lib/timers')
-rw-r--r--lib/timers/promises.js18
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/timers/promises.js b/lib/timers/promises.js
index 7c98ba35ec..76713bcf60 100644
--- a/lib/timers/promises.js
+++ b/lib/timers/promises.js
@@ -14,22 +14,14 @@ const {
} = require('internal/timers');
const {
- hideStackFrames,
+ AbortError,
codes: { ERR_INVALID_ARG_TYPE }
} = require('internal/errors');
-let DOMException;
-
-const lazyDOMException = hideStackFrames((message, name) => {
- if (DOMException === undefined)
- DOMException = internalBinding('messaging').DOMException;
- return new DOMException(message, name);
-});
-
function cancelListenerHandler(clear, reject) {
if (!this._destroyed) {
clear(this);
- reject(lazyDOMException('The operation was aborted', 'AbortError'));
+ reject(new AbortError());
}
}
@@ -64,8 +56,7 @@ function setTimeout(after, value, options = {}) {
// to 12.x, then this can be converted to use optional chaining to
// simplify the check.
if (signal && signal.aborted) {
- return PromiseReject(
- lazyDOMException('The operation was aborted', 'AbortError'));
+ return PromiseReject(new AbortError());
}
let oncancel;
const ret = new Promise((resolve, reject) => {
@@ -115,8 +106,7 @@ function setImmediate(value, options = {}) {
// to 12.x, then this can be converted to use optional chaining to
// simplify the check.
if (signal && signal.aborted) {
- return PromiseReject(
- lazyDOMException('The operation was aborted', 'AbortError'));
+ return PromiseReject(new AbortError());
}
let oncancel;
const ret = new Promise((resolve, reject) => {