Skip to content

fix(usenet): resolve send on closed channel panic in UsenetReader - #307

Merged
javi11 merged 1 commit into
mainfrom
fix/usenet-reader-send-on-closed-channel
Feb 18, 2026
Merged

fix(usenet): resolve send on closed channel panic in UsenetReader#307
javi11 merged 1 commit into
mainfrom
fix/usenet-reader-send-on-closed-channel

Conversation

@javi11

@javi11 javi11 commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix race condition between Close() and Read()/Start() in UsenetReader that caused panic: send on closed channel
  • Remove close(b.init) from Close() — context cancellation handles shutdown instead
  • Add case <-ctx.Done() to downloadManager()'s initial select for clean exit on context cancellation

Test plan

  • go build ./internal/usenet/ compiles without errors
  • go test ./internal/usenet/ passes all tests
  • Deploy and verify no more send on closed channel panics under concurrent file reads

🤖 Generated with Claude Code

Race condition between Close() and Read()/Start(): Close() would close
the init channel while Read() could concurrently send on it via
initDownload.Do(), causing a panic.

Remove close(b.init) from Close() and add ctx.Done() case to
downloadManager's initial select so it exits via context cancellation
instead of relying on channel closure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@javi11
javi11 merged commit a55903d into main Feb 18, 2026
1 check passed
@javi11
javi11 deleted the fix/usenet-reader-send-on-closed-channel branch February 24, 2026 08:45
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