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

Method waitForWorker

lib/internal/modules/esm/hooks.js:540–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

538 }
539
540 waitForWorker() {
541 if (!this.#isReady) {
542 const { kIsOnline } = require('internal/worker');
543 if (!this.#worker[kIsOnline]) {
544 debug('wait for signal from worker');
545 AtomicsWait(this.#lock, WORKER_TO_MAIN_THREAD_NOTIFICATION, 0);
546 const response = this.#worker.receiveMessageSync();
547 if (response == null) { return; }
548 if (response.message.status === 'exit') {
549 process.exit(response.message.body);
550 }
551
552 // ! This line catches initialization errors in the worker thread.
553 this.#unwrapMessage(response);
554 }
555
556 this.#isReady = true;
557 }
558 }
559
560 /**
561 * Invoke a remote method asynchronously.

Callers 3

makeAsyncRequestMethod · 0.95
makeSyncRequestMethod · 0.95

Calls 5

#unwrapMessageMethod · 0.95
receiveMessageSyncMethod · 0.80
requireFunction · 0.50
debugFunction · 0.50
exitMethod · 0.45

Tested by

no test coverage detected