Skip to content

Function: processLockAttached()

processLockAttached(): Promise<void>

In a worker, resolve once the attachProcessLock port has arrived.

Only needed on the attach path, and safe to await regardless: it returns immediately when the worker already has a port (the processLockWorkerOptions case) or when called on the main thread, so shared worker code does not branch on how it was started.

A parentPort listener keeps the worker alive, which is CORRECT here and deliberately not unref’d: this promise is pending work, and a worker allowed to exit while awaiting its port would die silently instead of locking. The listener is removed as soon as the port lands, so the worker is free to exit again the moment the wait is over.

Promise<void>