Skip to content

Commit 29b5236

Browse files
benjamingrdanielleadams
authored andcommitted
timers: reject with AbortError on cancellation
PR-URL: #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>
1 parent 4127eb2 commit 29b5236

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

‎lib/timers/promises.js‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,14 @@ const {
1414
}=require('internal/timers');
1515

1616
const{
17-
hideStackFrames,
17+
AbortError,
1818
codes: {ERR_INVALID_ARG_TYPE}
1919
}=require('internal/errors');
2020

21-
letDOMException;
22-
23-
constlazyDOMException=hideStackFrames((message,name)=>{
24-
if(DOMException===undefined)
25-
DOMException=internalBinding('messaging').DOMException;
26-
returnnewDOMException(message,name);
27-
});
28-
2921
functioncancelListenerHandler(clear,reject){
3022
if(!this._destroyed){
3123
clear(this);
32-
reject(lazyDOMException('The operation was aborted','AbortError'));
24+
reject(newAbortError());
3325
}
3426
}
3527

@@ -64,8 +56,7 @@ function setTimeout(after, value, options = {}) {
6456
// to 12.x, then this can be converted to use optional chaining to
6557
// simplify the check.
6658
if(signal&&signal.aborted){
67-
returnPromiseReject(
68-
lazyDOMException('The operation was aborted','AbortError'));
59+
returnPromiseReject(newAbortError());
6960
}
7061
letoncancel;
7162
constret=newPromise((resolve,reject)=>{
@@ -115,8 +106,7 @@ function setImmediate(value, options = {}) {
115106
// to 12.x, then this can be converted to use optional chaining to
116107
// simplify the check.
117108
if(signal&&signal.aborted){
118-
returnPromiseReject(
119-
lazyDOMException('The operation was aborted','AbortError'));
109+
returnPromiseReject(newAbortError());
120110
}
121111
letoncancel;
122112
constret=newPromise((resolve,reject)=>{

0 commit comments

Comments
 (0)