Architecture

Streaming RPC and versioning

Streaming RPCs carry multiple messages in one call. A server stream returns many responses, a client stream accepts many requests, and a bidirectional stream supports both directions. Messages retain their order within each individual gRPC stream. Stream lifetime, limits, cancellation and backpressure need explicit application design. Additive fields can be binary-compatible but may still break application assumptions, JSON consumers or strict validators. Reserve deleted field numbers and names; never reuse an old number for unrelated meaning. Test old and new clients in both directions. Do not equate an async generator with an actual gRPC transport or assume compatible bytes imply compatible business behavior. Sources: https://grpc.io/docs/what-is-grpc/core-concepts/, https://protobuf.dev/programming-guides/proto3/.

Formal Syntax & Structure

nodejs syntaxnodejs
Consume a bounded model stream (conceptual contract; see example)

Working Example

Example Snippetnodejs
import assert from 'node:assert/strict';let closed=false;async function* books(){try{for(const id of ['a','b','c'])yield id;}finally{closed=true;}}const found=[];for await(const id of books()){found.push(id);if(found.length===2)break;}assert.equal(closed,true);console.log(found.join(','));
Node.js Reference