fix(audio): unblock chunked reader close during chunk prefetch#304
Merged
devgianlu merged 3 commits intodevgianlu:masterfrom Apr 15, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes shutdown races and close behavior in the audio HTTP chunked reader by switching to context-based cancellation, ensuring in-flight requests/backoff are cancelable, and making latency metrics concurrency-safe; adds/updates unit + integration coverage around close/cancel behavior.
Changes:
- Introduce reader-scoped
context.Contextcancellation; normalize post-close failures tonet.ErrClosedand prevent new prefetch goroutines during shutdown. - Simplify chunk coordination by removing per-chunk error state and tightening fetch/prefetch synchronization.
- Add unit/integration tests covering close cancellation of in-flight fetches/reads and related concurrency behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| audio/chunked-reader.go | Context-cancelable shutdown, fetch/prefetch coordination changes, latency metric locking/snapshotting |
| audio/chunked-reader_internal_test.go | Unit tests for Close() interactions with concurrent fetch, in-flight requests, and transport/body read behavior |
| audio/chunked-reader_integration_test.go | Integration tests refactor + new close-cancels-in-flight-read coverage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This PR fixes a shutdown race in the audio chunked reader that I noticed in the CI run for another PR I opened: #302
Changes are essentially: