transport: unify server-side turn error handling#60
Merged
JoaoDiasAbly merged 1 commit intomainfrom Apr 21, 2026
Merged
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
Author
|
I think we first need to land these:
and then update the submodules pointers so CI will fully pass for this PR |
zknill
reviewed
Apr 21, 2026
Comment on lines
+475
to
+480
| const errInfo = new Ably.ErrorInfo( | ||
| `unable to stream response for turn ${turnId}; ${result.error.message}`, | ||
| ErrorCode.StreamError, | ||
| 500, | ||
| result.error instanceof Ably.ErrorInfo ? result.error : undefined, | ||
| ); |
Contributor
There was a problem hiding this comment.
This re-wraps errors thrown from encoder.appendEvent in pipeStream (i.e. ably publishes) but the js doc describes the ErrorCode.StreamError as though it's only an error from the LLM provider.
/**
* The source event stream threw during piping (e.g. LLM provider rate
* limit, model error, network failure).
*/
Comment on lines
+370
to
+378
| const errInfo = new Ably.ErrorInfo( | ||
| `unable to publish messages for turn ${turnId}; ${error instanceof Error ? error.message : String(error)}`, | ||
| ErrorCode.TurnLifecycleError, | ||
| 500, | ||
| error instanceof Ably.ErrorInfo ? error : undefined, | ||
| ); | ||
| logger?.error('Turn.addMessages(); publish failed', { turnId }); | ||
| turnOnError?.(errInfo); | ||
| throw errInfo; |
Contributor
There was a problem hiding this comment.
I don't think we should expose this error twice; once in the onError callback and once thrown from here. 🤔
zknill
approved these changes
Apr 21, 2026
Contributor
zknill
left a comment
There was a problem hiding this comment.
Remaining items are nits, so dropping a +1 and you can merge when fixed
cc909e3 to
a908f0d
Compare
Resolve three inconsistencies in server-side turn error handling flagged in AIT-667. - addMessages() and addEvents() now wrap publish failures as an Ably.ErrorInfo with code TurnLifecycleError and reject, matching start() and end(). All four lifecycle methods are consistent. - streamResponse() surfaces caught errors via StreamResult.error (preserving provider-specific type) and via the per-turn onError wrapped as an Ably.ErrorInfo with the new StreamError code. streamResponse() still does not throw. - The four lifecycle methods reject only; they do NOT also invoke onError. Per .claude/rules/ERRORS.md, an awaited method must not expose the same error through both a rejected promise and a callback. onError is reserved for paths with no other delivery channel (stream errors, onCancel handler failures). Add StreamError (104008) and broaden TurnLifecycleError (104003) to cover message and event publishes. Bump the ably-common submodule to include 104008. Tests cover publish failures for all four lifecycle methods, streamResponse stream errors (StreamResult.error + onError), and pipe-stream's new error-field contract. [AIT-667] Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0a47d57 to
d14a0d6
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.
Fix three inconsistencies in server transport error handling:
Broaden TurnLifecycleError (104003) to cover all turn publish failures. Add StreamError (104008) for source stream failures.
Tests cover the new onError paths for addMessages/addEvents/ streamResponse and the StreamResult.error contract on complete, cancel, and error paths.
AIT-667