Skip to content

Commit a0261d2

Browse files
mcollinaBethGriggs
authored andcommittedApr 19, 2021
Revert "timers: refactor to use optional chaining"
This reverts commit d8f535b. PR-URL: nodejs#38245 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4afcd55 commit a0261d2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
 

‎lib/timers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, {
171171
});
172172

173173
function clearTimeout(timer) {
174-
if (timer?._onTimeout) {
174+
if (timer && timer._onTimeout) {
175175
timer._onTimeout = null;
176176
unenroll(timer);
177177
return;

‎lib/timers/promises.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ function setTimeout(after, value, options = {}) {
5353
'boolean',
5454
ref));
5555
}
56-
if (signal?.aborted) {
56+
// TODO(@jasnell): If a decision is made that this cannot be backported
57+
// to 12.x, then this can be converted to use optional chaining to
58+
// simplify the check.
59+
if (signal && signal.aborted) {
5760
return PromiseReject(new AbortError());
5861
}
5962
let oncancel;
@@ -95,7 +98,10 @@ function setImmediate(value, options = {}) {
9598
'boolean',
9699
ref));
97100
}
98-
if (signal?.aborted) {
101+
// TODO(@jasnell): If a decision is made that this cannot be backported
102+
// to 12.x, then this can be converted to use optional chaining to
103+
// simplify the check.
104+
if (signal && signal.aborted) {
99105
return PromiseReject(new AbortError());
100106
}
101107
let oncancel;

0 commit comments

Comments
 (0)
Please sign in to comment.