pi-mono/packages/chord/test/next-node/fixtures/workers/child.ts
Mario Zechner 8959ad6e68 feat(chord): Chord v2 slice 10, HTTP and workers
chord/next/http: a Web fetch handler built from the registry Http (routes, wraps,
sockets, hosts, relays, CSP sources) and Authenticators, responses as descriptions,
a security baseline on by default, Chord's own Node listener as a host-lifetime
object, nodeRequest for apps mounting it, links and plugin sockets.
chord/next/workers: a forked worker per address, started on demand, stopped when
idle, never restarted by itself, plugins built by the server and shipped.
Plugins: kinds with platform and host packages, createPluginRuntime, scripts(kind),
rollout results per host, imports of other plugins by name. Kernel: RouteHandle
(retry, suspend), no route backoff, anonymous host.root, origins only from relays.
ws is an optional peer dependency.
2026-10-31 20:40:36 +00:00

12 lines
604 B
TypeScript

// Fixture child process (slice 10): writes to stdout and stderr, spawns a grandchild, sends a link frame and a control
// message at once, then lives until killed.
import { spawn } from "node:child_process";
import { envelope } from "../../../../src/next-node/workers/control.ts";
const grandchild = spawn(process.execPath, ["-e", "setTimeout(() => {}, 60000)"], { stdio: "ignore" });
process.stdout.write(`grandchild ${grandchild.pid}\n`);
process.stderr.write("an error line\n");
process.send?.(new Uint8Array([1, 2, 3]));
process.send?.(envelope({ kind: "started" }));
setInterval(() => {}, 1000);