Skip to main content

TypeScript SDK notes

Package: @superdurable/dex (examples target ^0.1.3+).

Async handlers

Step.waitFor, Step.execute, and RPC methods may return a Promise. The Worker runs on Node's single event loop, so an async handler that awaits Client (startFlow, waitForFlow, invokeRPC, …) yields the loop. The same Worker keeps serving other WorkerService calls — including a child Flow or RPC you just started.

async execute(_context: Context, childId: string): Promise<StepDecision> {
await getClient().startFlow(childFlow, childId, input);
const output = await getClient().waitForFlow(childId, stringCodec, 5_000);
return gracefulComplete(output);
}

Synchronous handlers remain valid. Do not block the event loop (Atomics.wait, spawnSync). Prefer short waitForFlow timeouts plus Step retry over one unbounded poll.

Examples under examples/typescript use a shared getClient() holder set at process start — no second “sync Worker” process.

Idioms that differ from Python

ConcernTypeScript
TimersTimer.byDuration(ms) (milliseconds)
CodecsExplicit inputCodec / stringCodec / jsonCodec on Steps and RPCs
NamesAlways implement getFlowType() / getStepType()
ClientPromise-based: await client.startFlow(...)
RPC@rpc({ name, inputCodec, outputCodec })return { output }

See also the sdk-typescript README and parent–child / scalable parallel patterns.