Summary
The custom linter detected 6 issues where context cancel functions are not deferred immediately after context.WithCancel, context.WithTimeout, or context.WithDeadline calls. This violates the context lifecycle safety rule and can lead to goroutine leaks.
Affected Files
- pkg/workflow/action_resolver.go (line 137)
- pkg/workflow/safe_outputs_actions.go (line 291)
- pkg/cli/mcp_inspect_mcp.go (lines 196, 208, 285, 297) — 4 occurrences
Pattern
All findings follow the same anti-pattern:
ctx, cancel := context.WithCancel(parent)
// ❌ NO defer here - cancel may never be called
// ... code that may panic or return ...
cancel()
Correct pattern:
ctx, cancel := context.WithCancel(parent)
defer cancel() // ✅ Deferred immediately
// ... safe to use ctx and early return ...
Validation
Run make golint-custom to verify all 6 issues are resolved.
Remediation Checklist
Generated by 🧌 LintMonster · haiku45 105.9K · ◷
Summary
The custom linter detected 6 issues where context cancel functions are not deferred immediately after
context.WithCancel,context.WithTimeout, orcontext.WithDeadlinecalls. This violates the context lifecycle safety rule and can lead to goroutine leaks.Affected Files
Pattern
All findings follow the same anti-pattern:
Correct pattern:
Validation
Run
make golint-customto verify all 6 issues are resolved.Remediation Checklist
defer cancel()immediately after context creationmake golint-customto verify