fix: goroutine leak in UsenetReader.Close() and Go idiom modernization - #429
Merged
Conversation
Use the reader's own context (b.ctx) instead of context.Background() in UsenetReader.Close() so the log call respects graceful shutdown. Handle previously-ignored LastInsertId() errors in AddToQueue and AddBatchToQueue across both QueueRepository and Repository, and deduplicate the rg.Clear() cleanup in Close() that was duplicated across both select branches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…de quality - Use subtle.ConstantTimeCompare for download key authentication to prevent timing attacks - Add io.LimitReader (50MB) cap on Prowlarr NZB downloads to prevent DoS - Validate Stremio streamType against whitelist and check strconv.Atoi errors - Extract duplicate hashAPIKey to shared internal/auth package - Replace fmt.Printf with structured slog calls in config/manager.go - Convert ~38 slog calls to context-aware variants across 7 files - Store context in rclone decrypter struct to replace context.TODO() - Defer file.Close() in pathutil to prevent leak on Write panic Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add second cond.Broadcast() after clearing rg on the timeout path in UsenetReader.Close() to wake goroutines that entered cond.Wait() after the initial broadcast, preventing goroutine accumulation. Also apply go fix modernizations: bytes.SplitSeq, strings.Cut/CutPrefix/ CutSuffix, remove unnecessary loop variable captures, and simplify min/max expressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
yoshitaka420
pushed a commit
to yoshitaka420/altmount
that referenced
this pull request
Jun 1, 2026
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.
Summary
cond.Broadcast()after clearingrgon the timeout path inUsenetReader.Close(), waking goroutines that enteredcond.Wait()after the initial broadcast (confirmed via pprof: 26 stuck downloadManager + 25 stuck close-waiter goroutines)go fix ./...):bytes.SplitSeq,strings.Cut/CutPrefix/CutSuffix, remove unnecessary loop variable captures, simplifymin/maxexpressionsTest plan
go build ./...passesgo test ./internal/usenet/...passes🤖 Generated with Claude Code
Co-author @firestaerter3