Skip to content
1 min read · 211 words

Type Alias: ChildResolver

ts
type ChildResolver = (ctx: {
  spec: IsolatedServiceSpec;
}) => IsolatedChildLike | Promise<IsolatedChildLike>;

Defined in: src/batteries/isolation/child_process/transport.ts:141

A BYO-spawner resolver — the seam for callers who need their own process manager (a pool, custom stdio, a sandboxing wrapper, or a library like execa) instead of this module's own default fork(). Invoked once per connect() (including every recycle()), i.e. once per guest spawn.

Parameters

ParameterType
ctx{ spec: IsolatedServiceSpec; }
ctx.specIsolatedServiceSpec

Returns

| IsolatedChildLike | Promise<IsolatedChildLike>

Remarks

The resolver receives the fully-resolved @nhtio/adk/batteries/isolation!IsolatedServiceSpec so it can name/label the spawned process (e.g. for logging), but is otherwise free to spawn however it likes — this transport only requires the returned value to satisfy IsolatedChildLike.

A returned execa { ipc: true } subprocess is itself thenable (execa mixes .then/.catch/ .finally onto it so it can double as "the child" and "a promise for its exit result"). This transport's own spawnChild internals guard against that value being mistaken for a real Promise and adopted (which would silently defer "spawned" until the child EXITS) — a resolver author does not need to do anything special here, this is called out purely so the mechanism is documented in one place close to where a resolver returns its child.