Skip to content

CONCEPT Cited by 1 source

Promise pipelining

Definition

Promise pipelining is an RPC optimization inherited from Cap'n Proto where a caller can invoke a method on a not-yet-resolved future value before the value has fully returned from the remote side. The RPC system sends both the original call and the dependent call together, eliminating a round trip.

// session is not yet resolved — it's a handle to a future value
const session = api.authenticate(apiKey);
// whoami() is sent immediately, pipelined on the pending session
const name = await session.whoami();

The caller doesn't wait for authenticate() to finish before asking for whoami(). The RPC layer says: "once authentication creates the session, call whoami() on it." This saves one network round trip compared to sequential await.

Workers RPC implementation

In Cloudflare Workers RPC, promise-like values returned from step.do() or any RPC call support pipelining. Calling a method on the returned Promise-like handle sends the pipelined call to the remote side early.

This is why a fluent rollback API (step.do("charge", chargeCard).rollback(refundCharge)) was rejected for Workflows: .rollback() chained on the step.do() result would look like a pipelined method call on the step's output, not a configuration of the step itself. The semantic ambiguity between "call rollback on the step result" and "register rollback as step metadata" made the fluent form untenable. (Source: sources/2026-06-25-cloudflare-saga-rollbacks-for-workflows.)

Origin

Promise pipelining originates in the E programming language and was systematized in Cap'n Proto's RPC design. The core insight: if you know you'll call method B on the result of method A, sending both together eliminates the latency of waiting for A's response before issuing B.

Seen in

Last updated · 608 distilled / 1,858 read