Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "timers: refactor to use optional chaining" #38245

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, {
});

function clearTimeout(timer) {
if (timer?._onTimeout) {
if (timer && timer._onTimeout) {
timer._onTimeout = null;
unenroll(timer);
return;
Expand Down
10 changes: 8 additions & 2 deletions lib/timers/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function setTimeout(after, value, options = {}) {
'boolean',
ref));
}
if (signal?.aborted) {
// TODO(@jasnell): If a decision is made that this cannot be backported
// to 12.x, then this can be converted to use optional chaining to
// simplify the check.
if (signal && signal.aborted) {
return PromiseReject(new AbortError());
}
let oncancel;
Expand Down Expand Up @@ -95,7 +98,10 @@ function setImmediate(value, options = {}) {
'boolean',
ref));
}
if (signal?.aborted) {
// TODO(@jasnell): If a decision is made that this cannot be backported
// to 12.x, then this can be converted to use optional chaining to
// simplify the check.
if (signal && signal.aborted) {
return PromiseReject(new AbortError());
}
let oncancel;
Expand Down