method

bun.Spawn.SpawnOptions.ipc

message: any,
subprocess: Subprocess<In, Out, Err>,
handle?: unknown
): void;

When specified, Bun opens an IPC channel to the subprocess. The passed callback is called for incoming messages, and subprocess.send can send messages to the subprocess. Messages are serialized using the JSC serialize API, which allows the same types that postMessage/structuredClone supports.

The subprocess can send and receive messages with process.send and process.on("message"), respectively. This is the same API that Node.js exposes when child_process.fork() is used.

This is only compatible with processes that are other bun instances.

@param subprocess

The Subprocess that received the message