Skip to content

fix(test): prevent Mercury v02 goroutine leak in timeout test#21962

Open
Fletch153 wants to merge 1 commit intodevelopfrom
fix/CORE-2372-mercury-v02-goroutine-leak
Open

fix(test): prevent Mercury v02 goroutine leak in timeout test#21962
Fletch153 wants to merge 1 commit intodevelopfrom
fix/CORE-2372-mercury-v02-goroutine-leak

Conversation

@Fletch153
Copy link
Copy Markdown
Collaborator

Summary

  • TestV02_DoMercuryRequestV02_Timeout panicked with "Log in goroutine after Test has completed"
  • Root cause 1: setupClient never called StartOnce, so c.Close() (via StopOnce) was a no-op — goroutines were never cleaned up
  • Root cause 2: Mock used time.Sleep(15s) which ignored context cancellation
  • Fix: Call StartOnce in setupClient so Close() properly waits for goroutines. Replace time.Sleep with context-aware select and return typed nil response with error

Test plan

  • Passes with -count=20 -race locally (202s, no panics)
  • CI passes

Fixes: CORE-2372

TestV02_DoMercuryRequestV02_Timeout panicked with "Log in goroutine
after Test has completed" because:

1. The client's Close() uses StopOnce which requires Start() — but
   the test never started the service, so Close() was a no-op
2. The mock used time.Sleep(15s) which ignored context cancellation,
   keeping goroutines alive after the test completed

Fix by calling StartOnce in setupClient so Close() properly waits for
goroutines, and replacing the mock's time.Sleep with a context-aware
select that exits promptly on cancellation.

Fixes: CORE-2372
@Fletch153 Fletch153 requested a review from a team as a code owner April 10, 2026 13:54
@github-actions
Copy link
Copy Markdown
Contributor

👋 Fletch153, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@trunk-io
Copy link
Copy Markdown

trunk-io bot commented Apr 10, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cl-sonarqube-production
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant