MCPcopy Index your code
hub / github.com/nodejs/node / waitUntil

Function waitUntil

test/common/inspector-helper.js:555–572  ·  view source on GitHub ↗

* When waiting for inspector events, there might be no handles on the event * loop, and leads to process exits. * * This function provides a utility to wait until a inspector event for a certain * time. * @returns {Promise}

(session, eventName, timeout = 1000)

Source from the content-addressed store, hash-verified

553 * @returns {Promise}
554 */
555function waitUntil(session, eventName, timeout = 1000) {
556 const resolvers = Promise.withResolvers();
557 const timer = setTimeout(() => {
558 resolvers.reject(new Error(`Wait for inspector event ${eventName} timed out`));
559 }, timeout);
560
561 once(session, eventName)
562 .then((res) => {
563 resolvers.resolve(res);
564 clearTimeout(timer);
565 }, (error) => {
566 // This should never happen.
567 resolvers.reject(error);
568 clearTimeout(timer);
569 });
570
571 return resolvers.promise;
572}
573
574module.exports = {
575 NodeInstance,

Calls 6

rejectMethod · 0.80
setTimeoutFunction · 0.50
onceFunction · 0.50
clearTimeoutFunction · 0.50
thenMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…