Skip to content

fix(tts): cancel() ends a reader following the request being written - #280

Merged
bgotthold-aai merged 1 commit into
masterfrom
ben/tts-session-cancel-watermark
Oct 23, 2026
Merged

bgotthold-aai merged 1 commit into
masterfrom
ben/tts-session-cancel-watermark

Conversation

@bgotthold-aai

Copy link
Copy Markdown
Contributor

What

session.cancel() did not end an audio() iteration opened with no id (the one that follows the text being written, the README's token-streaming pattern) when the cancel came before the flush: the cancel takes the same flush id that reader was waiting on, and the watermark checks compared with < and >, so the reader missed it by one and waited until the session ended. The comparisons are now <= / >=, and the watermark starts at -1 so request 0 is not dropped by the initial value. Sync and async; three tests. Found while porting the session to the Node SDK (assemblyai-node-sdk #200).

🤖 Generated with Claude Code

A `Cancel` takes the next flush_id, the same id `audio()` with no id uses
for the text being written, so the watermark comparisons (`<`, `>`) missed
that reader by one and it waited until the session ended. Compare with
`<=` / `>=` and start the watermark at -1 so the first request is not
dropped. Found porting the session to the Node SDK.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@bgotthold-aai
bgotthold-aai merged commit 24d657a into master Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant