[AIT-667] spec/ait: extend error handling for turn operations and stream failures#449
Merged
JoaoDiasAbly merged 1 commit intoai-transport-featuresfrom Apr 21, 2026
Conversation
zknill
approved these changes
Apr 21, 2026
45b6c44 to
4cce4fc
Compare
Fixes inconsistencies in server transport error handling: - addMessages() and addEvents() must reject with an Ably.ErrorInfo (code TurnLifecycleError) on publish failure, wrapping the underlying error as cause. The per-turn onError callback is NOT invoked — per the project's single-delivery-channel rule, awaited methods surface errors via promise rejection only (new AIT-ST5c). - end() publish failure gets the same explicit treatment (new AIT-ST7b). - streamResponse() stream errors preserve the original Error in StreamResult.error and invoke onError with a wrapped Ably.ErrorInfo, allowing server-side callers to distinguish provider errors such as rate limits while giving observability a standardised type (refined AIT-ST6b3). onError is the single ErrorInfo delivery path for streamResponse since the method does not throw. Also documents the deliberate decision that error details do NOT propagate automatically to the client transport (new AIT-ST6b4): server implementations forward details explicitly (e.g. via onMessage) to avoid leaking internals and to avoid imposing a protocol contract on all codecs. Broadens the TurnLifecycleError (104003) description to cover all turn publish failures, not just lifecycle events. Adds new error code StreamError (104008) for source stream failures. Refs: AIT-667 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4cce4fc to
a14781d
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three inconsistencies in server transport error handling identified in the PR #18 review and captured in AIT-667:
addMessages()/addEvents()now call the per-turnonErroron publish failure (parity withstart()andend()).end()publish-failure behaviour is made explicit for parity withstart().streamResponse()surfaces the caught error viaStreamResult.error(preserving the original type) and viaonError(wrapped asAbly.ErrorInfo).It also records the deliberate decision on client-side error propagation.
New/changed spec points
AIT-ST5c(new)addMessages()/addEvents()must invokeonErrorand re-throw.AIT-ST6b3(refined)streamResponse()must not throw on stream errors;StreamResult.errormust carry the original caught error;onErrormust be invoked with a wrappedAbly.ErrorInfo.AIT-ST6b4(new)onMessage/ application events. Rationale: avoid leaking internals and imposing a protocol contract on all codecs.AIT-ST7b(new)end()publish failure must invokeonErrorand re-throw.Error codes
TurnLifecycleError(104003) — description broadened to cover all turn publish failures (lifecycle event, message, or event).StreamError(104008) — new code for source event stream failures during piping (e.g. LLM provider rate limit, model error).Related
ably-ai-transport-jsto follow, on branchfix/AIT-667.Test plan
ably-common/protocol/errors.json🤖 Generated with Claude Code