Skip to content

Commit 6799738

Browse files
benjamingrtargos
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 5acf0a5 commit 6799738

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

‎lib/internal/timers/promises.js‎

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

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

2121
const{ validateAbortSignal }=require('internal/validators');
2222

23-
letDOMException;
24-
25-
constlazyDOMException=hideStackFrames((message,name)=>{
26-
if(DOMException===undefined)
27-
DOMException=internalBinding('messaging').DOMException;
28-
returnnewDOMException(message,name);
29-
});
30-
3123
functioncancelListenerHandler(clear,reject){
3224
if(!this._destroyed){
3325
clear(this);
34-
reject(lazyDOMException('The operation was aborted','AbortError'));
26+
reject(newAbortError());
3527
}
3628
}
3729

@@ -61,8 +53,7 @@ function setTimeout(after, value, options = {}) {
6153
// to 12.x, then this can be converted to use optional chaining to
6254
// simplify the check.
6355
if(signal&&signal.aborted){
64-
returnPromiseReject(
65-
lazyDOMException('The operation was aborted','AbortError'));
56+
returnPromiseReject(newAbortError());
6657
}
6758
letoncancel;
6859
constret=newPromise((resolve,reject)=>{
@@ -107,8 +98,7 @@ function setImmediate(value, options = {}) {
10798
// to 12.x, then this can be converted to use optional chaining to
10899
// simplify the check.
109100
if(signal&&signal.aborted){
110-
returnPromiseReject(
111-
lazyDOMException('The operation was aborted','AbortError'));
101+
returnPromiseReject(newAbortError());
112102
}
113103
letoncancel;
114104
constret=newPromise((resolve,reject)=>{

0 commit comments

Comments
 (0)