diff --git a/doc/api/timers.md b/doc/api/timers.md index 1a9c6fa861dc7b..7f3b11fe1f6d08 100644 --- a/doc/api/timers.md +++ b/doc/api/timers.md @@ -521,6 +521,9 @@ added: * `delay` {number} The number of milliseconds to wait before resolving the promise. * `options` {Object} + * `ref` {boolean} Set to `false` to indicate that the scheduled `Timeout` + should not require the Node.js event loop to remain active. + **Default:** `true`. * `signal` {AbortSignal} An optional `AbortSignal` that can be used to cancel waiting. * Returns: {Promise} diff --git a/lib/timers/promises.js b/lib/timers/promises.js index d577ac9240ec17..7343a39615a9b7 100644 --- a/lib/timers/promises.js +++ b/lib/timers/promises.js @@ -131,22 +131,18 @@ function setImmediate(value, options = kEmptyObject) { } async function* setInterval(after, value, options = kEmptyObject) { - try { - if (typeof after !== 'undefined') { - validateNumber(after, 'delay'); - } + if (typeof after !== 'undefined') { + validateNumber(after, 'delay'); + } - validateObject(options, 'options'); + validateObject(options, 'options'); - if (typeof options?.signal !== 'undefined') { - validateAbortSignal(options.signal, 'options.signal'); - } + if (typeof options?.signal !== 'undefined') { + validateAbortSignal(options.signal, 'options.signal'); + } - if (typeof options?.ref !== 'undefined') { - validateBoolean(options.ref, 'options.ref'); - } - } catch (err) { - return PromiseReject(err); + if (typeof options?.ref !== 'undefined') { + validateBoolean(options.ref, 'options.ref'); } const { signal, ref = true } = options;