Fix ReclaimFunds hanging forever when the context is cancelled mid-sweep - #276
Draft
damilolaedwards wants to merge 1 commit into
Draft
Conversation
OnComplete is documented as always being called once transaction processing finishes, regardless of success or failure. The guard that returns early when the context is already cancelled skipped that contract entirely, returning before the callback was ever wired up. ReclaimFunds depends on that contract: it fires one goroutine per wallet to send a reclaim transaction and only calls wg.Done() from inside OnComplete, then waits on the group. Both a daemon shutdown and a spammer pause cancel the same context that gets passed down to these sends, so any reclaim still being dispatched at that moment would never release its slot in the wait group, leaving the whole reclaim, and the spammer run it belongs to, stuck forever with no timeout to recover. Now the early-return path calls OnComplete with the context error before returning, so every caller that relies on it firing keeps working correctly once the context is cancelled. Added tests that drive the real SendTransaction path with an already-cancelled context, one asserting OnComplete still fires, and one mirroring ReclaimFunds's own wait group wiring end to end.
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
Test plan
-race.