Skip to content

fix(importer): fix context cancellation propagation to prevent stuck imports - #172

Merged
javi11 merged 1 commit into
mainfrom
fix/context-cancellation-propagation
Dec 28, 2025
Merged

fix(importer): fix context cancellation propagation to prevent stuck imports#172
javi11 merged 1 commit into
mainfrom
fix/context-cancellation-propagation

Conversation

@javi11

@javi11 javi11 commented Dec 28, 2025

Copy link
Copy Markdown
Collaborator

Summary

  • Fix double-unlock panic bug in Stop() method that caused crashes on service shutdown
  • Add ctx.Done() checks in UsenetFile.Read() with timeout for reader creation to prevent network hangs
  • Add context checks before expensive operations in RAR and 7zip archive processors
  • Add context parameter to AddToQueue() and update all API handler callers
  • Add context parameter to createNzbFileAndPrepareItem() and isFileAlreadyInQueue()
  • Replace context.Background() with proper service context in logging calls
  • Fix notifyRcloneVFS to derive timeout from parent context for proper cancellation propagation

Test plan

  • Run go build ./... to verify compilation
  • Run go test ./internal/importer/... to verify existing tests pass
  • Manual test: Start an import, cancel mid-process, verify clean cancellation
  • Manual test: Stop the service, verify no panic from double-unlock

🤖 Generated with Claude Code

…imports

Fixes several issues where the import process could get stuck because context
cancellation wasn't properly propagated:

- Fix double-unlock panic bug in Stop() method
- Add ctx.Done() checks in UsenetFile.Read() with timeout for reader creation
- Add context checks before expensive operations in RAR and 7zip processors
- Add context parameter to AddToQueue() and update all callers
- Add context parameter to createNzbFileAndPrepareItem() and isFileAlreadyInQueue()
- Replace context.Background() with proper service context in logging calls
- Fix notifyRcloneVFS to derive timeout from parent context

These changes ensure that when an import is cancelled, the cancellation properly
propagates through all operations including network reads, archive analysis,
and database operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@javi11
javi11 merged commit 236939e into main Dec 28, 2025
1 check passed
@javi11
javi11 deleted the fix/context-cancellation-propagation branch February 4, 2026 13:41
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