MCPcopy Create free account
hub / github.com/nodejs/node / [kOnExit]

Method [kOnExit]

lib/internal/worker.js:393–410  ·  view source on GitHub ↗
(code, customErr, customErrReason)

Source from the content-addressed store, hash-verified

391 }
392
393 [kOnExit](code, customErr, customErrReason) {
394 debug(`[${threadId}] hears end event for Worker ${this.threadId}`);
395 drainMessagePort(this[kPublicPort]);
396 drainMessagePort(this[kPort]);
397 destroyMainThreadPort(this.threadId);
398 this.removeAllListeners('message');
399 this.removeAllListeners('messageerrors');
400 this[kPublicPort].unref();
401 this[kPort].unref();
402 this[kDispose]();
403 if (customErr) {
404 debug(`[${threadId}] failing with custom error ${customErr} \
405 and with reason ${customErrReason}`);
406 this.emit('error', new errorCodes[customErr](customErrReason));
407 }
408 this.emit('exit', code);
409 this.removeAllListeners();
410 }
411
412 [kOnCouldNotSerializeErr]() {
413 this.emit('error', new ERR_WORKER_UNSERIALIZABLE_ERROR());

Callers

nothing calls this directly

Calls 5

destroyMainThreadPortFunction · 0.85
debugFunction · 0.50
removeAllListenersMethod · 0.45
unrefMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected