From d9b56fe2950af7463438a47b90e5d65ce8aafde5 Mon Sep 17 00:00:00 2001 From: Giora Guttsait Date: Tue, 20 Apr 2021 23:13:59 +0300 Subject: [PATCH] timers: remove redundant unref calls PR-URL: https://github.com/nodejs/node/pull/38320 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Rich Trott --- lib/timers/promises.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/timers/promises.js b/lib/timers/promises.js index ec13e873d84..1f245580f86 100644 --- a/lib/timers/promises.js +++ b/lib/timers/promises.js @@ -61,8 +61,7 @@ function setTimeout(after, value, options = {}) { } let oncancel; const ret = new Promise((resolve, reject) => { - const timeout = new Timeout(resolve, after, args, false, true); - if (!ref) timeout.unref(); + const timeout = new Timeout(resolve, after, args, false, ref); insert(timeout, timeout._idleTimeout); if (signal) { oncancel = FunctionPrototypeBind(cancelListenerHandler, @@ -141,8 +140,7 @@ async function* setInterval(after, value, options = {}) { callback(); callback = undefined; } - }, after, undefined, true, true); - if (!ref) interval.unref(); + }, after, undefined, true, ref); insert(interval, interval._idleTimeout); if (signal) { onCancel = () => {