From 85e046e2097ad949e373c8129a34f0349aca3584 Mon Sep 17 00:00:00 2001 From: Devin Ivy Date: Tue, 21 Jul 2026 22:56:42 -0700 Subject: [PATCH] docs: correct stale main-thread evaluation comment in worker-entry --- src/worker-entry.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/worker-entry.ts b/src/worker-entry.ts index 4056ade..58386ea 100644 --- a/src/worker-entry.ts +++ b/src/worker-entry.ts @@ -322,8 +322,10 @@ if (parentPort !== null && handshake?.runtimeId !== undefined) { await initRuntimeWorker(handshake, attachEndpointHandler); } -// parentPort is null when this module evaluates on the MAIN thread — user -// code importing peers.ts (e.g. a moroutine that dispatches to a peer) pulls -// this module in transitively. There is no endpoint to attach there; the -// handshake above is null on main too, so evaluation is inert by design. +// Normally this module only evaluates as a worker's entry module, where +// parentPort is set. Nothing in the library import graph pulls it in — +// peers.ts and runtime-worker receive its handler by injection, not by +// importing us — but an explicit import (e.g. from a test) can evaluate it +// on the MAIN thread, where parentPort is null and there is no endpoint to +// attach. The handshake above is null on main too, so evaluation is inert. if (parentPort !== null) attachEndpointHandler(parentPort); -- 2.51.2