fix: close redis connections on unsubscribe#2917
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Redis adapter adds a ChangesRedis subscription cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
Router image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@router/pkg/pubsub/redis/adapter.go`:
- Around line 108-111: The current call wraps zap.Error(err) inside fmt.Sprintf
with a %w verb which is invalid and breaks structured logging; replace the
fmt.Sprintf usage and call log.Error with a message string and pass
zap.Error(err) as a field (e.g., in the error handling after sub.Close() use
log.Error("error closing connection to redis", zap.Error(err))) so zap produces
structured error output; locate the block around sub.Close(), the log.Error
invocation, and the zap.Error(err) usage to make this change.
- Line 103: The call sub.PUnsubscribe(context.Background(), subConf.Channels...)
in the cleanup function can block Shutdown via p.closeWg.Wait(); replace the
background context with a context.WithTimeout (e.g., ctx, cancel :=
context.WithTimeout(context.Background(), <reasonableDuration>); defer cancel())
and pass ctx to sub.PUnsubscribe so the unsubscribe is bounded, and add "time"
to the imports if you use a time constant; ensure cleanup still calls
p.closeWg.Done() after the unsubscribe attempt and that
ProviderAdapter.Shutdown() relies on the bounded wait.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b0dda8b6-6496-4515-a4f0-810bd12ee3d3
📒 Files selected for processing (1)
router/pkg/pubsub/redis/adapter.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2917 +/- ##
==========================================
+ Coverage 66.26% 66.29% +0.02%
==========================================
Files 258 258
Lines 27309 27314 +5
==========================================
+ Hits 18097 18107 +10
+ Misses 7773 7770 -3
+ Partials 1439 1437 -2
🚀 New features to boost your workflow:
|
… (#123) * fix: close redis connections on unsubscribe * fix: use correct format identifier in Sprintf * fix: use fixed timeout for unsubscribe --------- Co-authored-by: Dominik Korittki <23359034+dkorittki@users.noreply.github.com>
Summary by CodeRabbit
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.