Skip to content

Commit 28724f0

Browse files
ShogunPandapull[bot]
authored andcommitted
timers: document ref option for scheduler.wait
PR-URL: nodejs#54605 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]>
1 parent 4f37955 commit 28724f0

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

doc/api/timers.md

+3
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ added:
525525
* `delay` {number} The number of milliseconds to wait before resolving the
526526
promise.
527527
* `options` {Object}
528+
* `ref` {boolean} Set to `false` to indicate that the scheduled `Timeout`
529+
should not require the Node.js event loop to remain active.
530+
**Default:** `true`.
528531
* `signal` {AbortSignal} An optional `AbortSignal` that can be used to
529532
cancel waiting.
530533
* Returns: {Promise}

lib/timers/promises.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,18 @@ function setImmediate(value, options = kEmptyObject) {
131131
}
132132

133133
async function* setInterval(after, value, options = kEmptyObject) {
134-
try {
135-
if (typeof after !== 'undefined') {
136-
validateNumber(after, 'delay');
137-
}
134+
if (typeof after !== 'undefined') {
135+
validateNumber(after, 'delay');
136+
}
138137

139-
validateObject(options, 'options');
138+
validateObject(options, 'options');
140139

141-
if (typeof options?.signal !== 'undefined') {
142-
validateAbortSignal(options.signal, 'options.signal');
143-
}
140+
if (typeof options?.signal !== 'undefined') {
141+
validateAbortSignal(options.signal, 'options.signal');
142+
}
144143

145-
if (typeof options?.ref !== 'undefined') {
146-
validateBoolean(options.ref, 'options.ref');
147-
}
148-
} catch (err) {
149-
return PromiseReject(err);
144+
if (typeof options?.ref !== 'undefined') {
145+
validateBoolean(options.ref, 'options.ref');
150146
}
151147

152148
const { signal, ref = true } = options;

0 commit comments

Comments
 (0)