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 = () => {