Skip to content

ApproveWaiter.Resolve goroutine leak fix #48

Merged
x2d7 merged 4 commits intorelease/v0.3.1from
fix/goroutine-leak-v0.3.1
Mar 7, 2026
Merged

ApproveWaiter.Resolve goroutine leak fix #48
x2d7 merged 4 commits intorelease/v0.3.1from
fix/goroutine-leak-v0.3.1

Conversation

@x2d7
Copy link
Owner

@x2d7 x2d7 commented Mar 7, 2026

Summary

Fix for a goroutine leak in ApproveWaiter on context cancellation.

Fix: Goroutine leak on context cancellation (#44)

ApproveWaiter.Resolve spawns a goroutine via resolveSync when it can't immediately send a verdict. This goroutine blocks on a.verdicts <- verdict. If the context is cancelled before or during Wait, it exits without draining the channel — leaving the goroutine blocked indefinitely.

The fix stores the context in ApproveWaiter when Wait is called, and uses it in resolveSync to unblock on cancellation:

// before
func (a *ApproveWaiter) resolveSync(verdict Verdict) {
    a.verdicts <- verdict
}

// after
func (a *ApproveWaiter) resolveSync(verdict Verdict) {
    select {
    case a.verdicts <- verdict:
    case <-a.ctx.Done():
    }
}

Closes #44

@x2d7 x2d7 added this to the v0.3.1 — Events Improvements milestone Mar 7, 2026
@x2d7 x2d7 merged commit a4bbd29 into release/v0.3.1 Mar 7, 2026
1 check passed
@x2d7 x2d7 deleted the fix/goroutine-leak-v0.3.1 branch March 7, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant