Calls
Methods and shapes
Section titled “Methods and shapes”- A method is addressed as
"<service>/<method>", e.g."chat/send". Names match[A-Za-z_][A-Za-z0-9_]*per segment and are case-sensitive. - Server methods and client methods are separate namespaces: a CALL from the client is resolved among server methods, and a CALL from the server among client methods.
- Shapes:
0unary,1server stream,2client stream,3bidirectional. “Server” and “client” here mean callee and caller: shape 1 means the callee streams to the caller, whichever side is the server.
CALL (0x10)
Section titled “CALL (0x10)”Opens a call stream. Header:
| Key | Field | Req. | Notes |
|---|---|---|---|
| 2 | method |
MUST | |
| 5 | shape |
MUST | Must match the contract’s shape for this method |
| 4 | deadline |
MAY | Milliseconds from the moment the callee receives CALL |
| 3 | meta |
MAY | Call metadata (§8.7) |
Data section: the call’s arguments, encoded as one codec array whose elements are the parameters in contract order. A method without parameters uses an empty array.
Callee checks, in order (each failure answers with ERROR and closes the call):
- Concurrency limit exceeded (WS, §6.5) → RESOURCE_EXHAUSTED. This check runs before the frame’s header and data are inspected any further.
- Unknown method → UNIMPLEMENTED.
- Shape mismatch, or the method is a notification → INVALID_ARGUMENT.
- Arguments fail to decode or have the wrong count, or capability
idempotencyis granted and thepavia-idempotency-keyexceeds 128 bytes (§8.7) → INVALID_ARGUMENT. - Authorization fails → PERMISSION_DENIED (or UNAUTHENTICATED for an anonymous session).
ITEM (0x11) and END (0x12)
Section titled “ITEM (0x11) and END (0x12)”- ITEM: header empty (or
metaon the first item, reserved); data section = one stream element, encoded per the contract’s item type for that direction. - END: closes the sender’s half successfully. Header MAY carry
metaas trailers. Data section empty. - For client streams and bidirectional calls, the caller sends END to signal “no more items”.
- For server streams and bidirectional calls, the callee sends END to signal successful completion.
RESULT (0x13) and ERROR (0x14)
Section titled “RESULT (0x13) and ERROR (0x14)”- RESULT (callee → caller, shapes 0 and 2): data section = the return value. A method returning unit encodes the codec’s unit value (§12.3). Header MAY carry
metaas trailers. - ERROR (callee → caller, any shape, at any point): header
code(§15.2, never 0) andmsg; MAY carrymeta. Data section MAY carry a typed error detail, encoded per the method’s declared error type (§12.2). If the method declares none, the data section MUST be empty. nx(key 45): an ERROR withnx: trueguarantees that the method handler was never invoked, so the caller may retry even a non-idempotent call transparently. Callees MUST set it for UNIMPLEMENTED, INVALID_ARGUMENT, PERMISSION_DENIED, UNAUTHENTICATED and RESOURCE_EXHAUSTED raised before dispatch, and for UNAVAILABLE raised after GOAWAY. Caller libraries (client or server) set it on locally generated errors that provably preceded any send, including a call to a detached, unknown or ended session (§8.8). An ERROR withoutnxmeans the outcome is unknown; only calls markedidempotent(§12.2), or carrying an idempotency key on a session where capabilityidempotencywas granted (§8.7), may be retried automatically.- Error disclosure: callees (server or client) MUST NOT put internal error text in
msgfor unexpected failures unless configured for development; they use code INTERNAL with a generic message. Errors the application raises deliberately (typed errors or explicit status codes) are sent as given.
CANCEL (0x15)
Section titled “CANCEL (0x15)”- Caller → callee, at any time before the response half closes. Header MAY carry
msg. - The callee MUST stop work promptly and MUST reply with ERROR CANCELLED unless it has already sent a terminal frame.
- After sending CANCEL, the caller MUST ignore everything on the stream except the terminal frame, which completes cleanup.
- A callee that receives CANCEL after it has already sent its terminal frame MUST ignore it (the two crossed in flight). A second CANCEL on the same stream is ignored likewise.
- On WebTransport, the caller MAY also reset the stream; the callee treats a reset as CANCEL (§6.3). A caller that has already finished its send side (END and FIN) cancels by sending STOP_SENDING on the stream instead; the callee treats STOP_SENDING as CANCEL and resets its send side, so no ERROR CANCELLED reaches the caller, which completes the call locally with CANCELLED.
Deadlines
Section titled “Deadlines”- The callee starts a timer when it receives CALL with
deadline. At expiry it cancels the handler and replies ERROR DEADLINE_EXCEEDED. - The caller’s library SHOULD also enforce the deadline locally (send CANCEL, complete with DEADLINE_EXCEEDED) to cover lost responses.
- Servers MAY enforce a maximum deadline and a default deadline for calls without one.
- For streaming shapes, the deadline covers the whole call, not individual items.
Metadata
Section titled “Metadata”metamaps names to text or bytes. Names are lowercase ASCII[a-z0-9-]. Total encoded size counts toward the header limit. A name that violates this grammar makes the header malformed (PROTOCOL_ERROR, §5.4.1).- Reserved names:
traceparent,tracestate: W3C Trace Context. Implementations SHOULD propagate them into their tracing systems.pavia-idempotency-key: an opaque caller-chosen key (≤ 128 bytes). A server that supports it MUST return the stored outcome of an earlier call with the same key instead of executing again, for a retention window it documents (default 5 min), and MUST answer with the stored RESULT/ERROR. This lets clients retry non-idempotent calls after transport loss. Servers advertise support with capabilityidempotency. Without that capability the key is ordinary metadata and is not an error. With it:- A key over 128 bytes is answered ERROR INVALID_ARGUMENT with
nx: true(§8.2, check 4). - Entries are scoped by (principal, or session ID for an anonymous session; method; key). The same key on another method is a different entry.
- Only RESULT and ERRORs raised by the handler are stored, never CANCELLED, DEADLINE_EXCEEDED or an ERROR with
nx: true. - A call whose key matches a call still in progress is answered ERROR ABORTED with
nx: true; the client backs off and retries.
- A key over 128 bytes is answered ERROR INVALID_ARGUMENT with
pavia-*: reserved for this specification. Receivers ignorepavia-*names they do not implement.
- Metadata is available to handlers and filters. It is never interpreted by the protocol otherwise.
Server-initiated calls (capability server-calls)
Section titled “Server-initiated calls (capability server-calls)”- The server opens a call stream to the client with CALL naming a client method. The same shapes and rules apply with roles reversed.
- The client library dispatches to the handler registered for that method. No handler → ERROR UNIMPLEMENTED.
- The client advertises in HELLO
limits.max_callshow many concurrent server-initiated calls it accepts; the server enforces it on both bindings (§6.5). - A server-initiated call to an unknown or ended session fails locally with NOT_FOUND and
nx: true; to a detached session, with UNAVAILABLE andnx: true(§7.8).
Ordering guarantees
Section titled “Ordering guarantees”- Frames within one stream are delivered in order.
- There is no ordering between streams, including between a call’s RESULT and notifications on the control stream. (Frameworks that run everything over one ordered connection behave differently.) An application that needs “notify after result” ordering must enforce it itself, e.g. by awaiting the result before notifying.
- On WebSocket, cross-stream order happens to be preserved in practice; applications MUST NOT rely on it, because the same code must work on WebTransport.
Undecodable data sections
Section titled “Undecodable data sections”A data section that fails to decode against its contract type is usually contract skew (§7.2), so its outcome is scoped to the call or message; the session and every other call continue.
- A callee that cannot decode an ITEM answers ERROR INVALID_ARGUMENT without
nx(the handler is already running). - A caller that cannot decode a RESULT, an ITEM or an ERROR detail completes the call locally with INTERNAL and sends CANCEL if the call is still open.
- An undecodable PUBLICATION, PRESENCE entry, SUBSCRIBED snapshot or DATAGRAM value is dropped and surfaced to the application as a local error event.
- CALL arguments follow §8.2 (check 4) and NOTIFY arguments §9.1.
From the specification: §8.1, §8.2, §8.3, §8.4, §8.5, §8.6, §8.7, §8.8, §8.9, §8.10.