Architecture

gRPC deadlines and errors

A deadline is the time by which an RPC should finish. A caller may stop waiting even though remote work has already committed; timeout does not imply rollback. Budget time across downstream calls rather than granting each dependency a fresh full timeout. In gRPC, DEADLINE_EXCEEDED indicates that the call exceeded its time budget; CANCELLED, INVALID_ARGUMENT, NOT_FOUND and UNAVAILABLE have distinct meanings. Retry only when the operation is safe to repeat and the remaining budget permits it. Cancellation is cooperative; a server must stop work and release resources where possible. A mutation may require an idempotency key and reconciliation. Do not blindly retry every failure or treat UNAVAILABLE as evidence that no mutation took place. Sources: https://grpc.io/docs/guides/deadlines/, https://grpc.io/docs/guides/status-codes/.

Formal Syntax & Structure

nodejs syntaxnodejs
Propagate a shrinking deadline (conceptual contract; see example)

Working Example

Example Snippetnodejs
import assert from 'node:assert/strict';function budget(deadline,now,reserve){return Math.max(0,deadline-now-reserve);}assert.equal(budget(100,105,5),0);console.log(budget(100,35,10),budget(100,90,10));
Node.js Reference