node:worker_threads runs scripts on separate threads; elide run does not exit while a worker is running.
Exports
Worker, isMainThread, isInternalThread, threadId, threadName, parentPort, workerData,
MessageChannel, MessagePort, BroadcastChannel, receiveMessageOnPort, postMessageToThread,
moveMessagePortToContext, getEnvironmentData, setEnvironmentData, markAsUntransferable,
isMarkedAsUntransferable, markAsUncloneable, getHeapSnapshot, SHARE_ENV, and resourceLimits.
Differences from Node
new Workerreads only theworkerData,eval,transferList, andenvoptions.- A missing script file emits
errorwith codeERR_WORKER_PATH. stdoutandstderrare always inherited from the parent.resourceLimitsis{}.- Posting a
ReadableStreamthrowsDataCloneError. - Posting to a terminated worker is a no-op.
--limit=workers=COUNTlimits how many workers a script may start; see Sandbox.