[management] run cancelPeerRoutines in goroutine in sync#5234
Conversation
📝 WalkthroughWalkthroughRefactors peer cleanup in Sync error paths by adding Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request fixes a potential deadlock issue in the Sync function by running the cancelPeerRoutines cleanup method in a goroutine when errors occur during peer synchronization.
Changes:
- Modified two error paths in the
Syncmethod to callcancelPeerRoutinesasynchronously (in a goroutine) instead of synchronously - This prevents deadlock when the calling function holds a peer lock that
cancelPeerRoutinesalso needs to acquire
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



Describe your changes
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
bug fix
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.