fix(voice): prevent RecorderIO shutdown write-loop noise#1378
fix(voice): prevent RecorderIO shutdown write-loop noise#1378toubatbrian merged 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: ff7b80f The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca3e31a95e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ('code' in error && (error as { code?: string }).code === 'ERR_INVALID_STATE') { | ||
| return true; |
There was a problem hiding this comment.
Restrict closed-stream detection to closure-specific cases
isWritableStreamClosedError() currently returns true for any error with code === 'ERR_INVALID_STATE', but that code is also used for non-closure stream-state failures; when this happens, RecorderIO.forward() will treat a real stream bug as expected teardown and break the loop without surfacing it. This can silently stop recording progress and hide actionable errors, so the predicate should also verify the message (or otherwise positively identify closed-stream conditions) before suppressing/log-skipping.
Useful? React with 👍 / 👎.
Summary
RecorderIOshutdown to prevent repeated writes during teardown:closing) and stop writes immediately when close startsforwardTaskbefore closing channelsisWritableStreamClosedError()intoagents/src/utils.tsfor reuseagents/src/voice/recorder_io/recorder_io.test.tsWhy
On disconnect, recorder background writes could race with stream closure and emit repeated
Invalid state: WritableStream is closederrors. This change makes post-close writes structurallyimpossible and treats teardown-expected closure as terminal, removing log spam.
Test Plan
pnpm test agents/src/voice/recorder_io/recorder_io.test.tsError writing RecorderIO output bufferlogs after disconnect