MCPcopy Create free account
hub / github.com/Effect-TS/effect / onMessage

Function onMessage

packages/platform/node/src/NodeWorkerRunner.ts:61–77  ·  view source on GitHub ↗
(message: WorkerRunner.PlatformMessage<I>)

Source from the content-addressed store, hash-verified

59 }
60 const port = WorkerThreads.parentPort ?? process
61 function onMessage(message: WorkerRunner.PlatformMessage<I>) {
62 if (message[0] === 0) {
63 const result = handler(0, message[1])
64 if (Effect.isEffect(result)) {
65 const fiber = runFork(result)
66 fiber.addObserver(onExit)
67 trackFiber(fiber)
68 }
69 } else {
70 if (WorkerThreads.parentPort) {
71 WorkerThreads.parentPort.close()
72 } else {
73 process.channel?.unref()
74 }
75 Deferred.doneUnsafe(closeLatch, Exit.void)
76 }
77 }
78 port.on("message", onMessage)
79
80 function onMessageError(cause: unknown) {

Callers

nothing calls this directly

Calls 4

runForkFunction · 0.85
addObserverMethod · 0.80
closeMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected