On this page
Synchronous execution primitives for `spawn` and `http`, the two effect methods Node cannot perform synchronously on its own main thread.
#typescript/src/effects_exec
#typescript/src/effects_exec
Synchronous execution primitives for the two effect methods Node cannot perform synchronously on the main thread: spawn (a concurrent child whose exit status must be readable later, synchronously, through Spawned.wait()) and http.
The effects API is synchronous by contract (ยง2.5.6 pins ctx.effects.run(argv, opts?) => Completed, not a Promise), because a forwarded carrier has to arrive at a later effect's parameter as a value, not as a pending promise. run gets that for free from spawnSync; these two do not, and each uses the smallest mechanism that gives it:
spawn: a worker thread starts the child and signals the main thread
through a SharedArrayBuffer flag (pid on start, exit code on close). The main thread blocks with Atomics.wait, which is permitted on Node's main thread, and drains the payload with receiveMessageOnPort.
http: a short-lived childnodeprocess performs the fetch and writes a
JSON envelope to stdout. No worker machinery is needed for a single request/response round trip, and a child process cannot leak a live handle back into the parent's event loop.
Neither mechanism degrades: a failure to start is thrown, never swallowed.
#SpawnedChild
export interface SpawnedChildA started child whose exit status can be awaited synchronously later.
#spawnConcurrent
export function spawnConcurrent(Starts a child concurrently and returns a handle whose wait() blocks the main thread synchronously. Throws if the child cannot be started.
#HttpResult
export interface HttpResultA performed HTTP request's raw result.
#httpSync
export function httpSync(Performs an HTTP request synchronously. Throws when the request fails.