[BUG]: Singleton state leak in matchmaking tests causes non-deterministic failures
Maintainers usually reply within 20 days
@mithunkc017-ship-it is already working on this.
Since Nov 12, 2026.
- #799 by @mithunkc017-ship-it — open
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Read backend/services/matchmaking_test.go and compare its cleanup pattern with backend/services/matchmaking_pool_test.go. Run the issue’s go test command to reproduce the shared pool counts, then ensure each test removes every user it adds. Done means repeated runs pass without leftover users affecting pool size assertions.
Written by the indexing model from the issue text.
Description
Bug Description
TestMatchmakingService and TestEloTolerance in services/matchmaking_test.go both operate on the same package-level MatchmakingService singleton (initialised once via sync.Once). Neither test registers a t.Cleanup to remove the users it adds to the pool.
Specifically, TestMatchmakingService adds user1 and user2, then removes only user1. user2 stays in the shared pool indefinitely. When TestEloTolerance runs afterwards, it adds its own user1/user2/user3 and asserts exact pool counts — but the leftover user2 from the previous test makes those counts wrong, causing the test to fail non-deterministically depending on run order and timing.
This is in contrast to matchmaking_pool_test.go, which already correctly uses t.Cleanup to remove every entry it adds.
Steps to Reproduce
- Run the matchmaking service tests multiple times or in verbose mode :
go test ./services/... -v -count=3 -run "TestMatchmakingService|TestEloTolerance"
- Observe intermittent failures on pool size assertions such as:
Expected 0 users in pool (no one started matchmaking), got 1
or
Expected 1 user remaining in pool (Charlie), got 2
Logs and Screenshots
--- FAIL: TestEloTolerance (0.11s)
matchmaking_test.go:79: Expected 0 users in pool (no one started matchmaking), got 1
--- FAIL: TestEloTolerance (0.11s)
matchmaking_test.go:110: Expected 1 user remaining in pool (Charlie), got 2
The failure is non-deterministic — it surfaces more reliably with -count=2 or higher, or when tests run in parallel.
Environment Details
- Language: Go
- Affected file: backend/services/matchmaking_test.go
- Related file (correct pattern): backend/services/matchmaking_pool_test.go
- Root cause: GetMatchmakingService() uses sync.Once — all tests share the same singleton pool with no isolation between test runs
- Go version: Any (not version-specific)
- OS: Any
Impact
Medium - Feature works but has issues
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
- Dominant language
- TypeScript
- Stars
- 108
- Forks
- 266
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/DebateAI
-
[BUG]: Comment, reply and team-join notifications link to wrong or non-existent frontend routesMay be free again @unnati-jaiswal24 claimed this 7 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AOSSIE-Org/DebateAI#811 · 2 comments ·
Maintainers usually reply within 20 days
-
[BUG]: Comment, reply and team-join notifications link to wrong or non-existent frontend routesPossibly taken @mithunkc017-ship-it claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
AOSSIE-Org/DebateAI#810 · 1 comment ·
Maintainers usually reply within 20 days
-
[BUG]: Inverted Mic icon causes input confusion in Bot Debate RoomPossibly taken @Rusky-1014 claimed this 11 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AOSSIE-Org/DebateAI#802 ·
Maintainers usually reply within 20 days
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pagePossibly taken @sujitkr268 claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/DebateAI#801 · 2 comments ·
Maintainers usually reply within 20 days
-
[BUG]: Live Debate Rooms page overflows horizontally on mobile screensMay be free again @SYED-IRTEZA-HUSSAIN-RIZVI claimed this 14 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
AOSSIE-Org/DebateAI#797 · 4 comments ·
Maintainers usually reply within 20 days
All issues in AOSSIE-Org/DebateAI
Similar issues
-
enhancement status:needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
dongdongbh/Mindwtr#1625 ·
Maintainers usually reply within 1 day
-
area/ui-schema good first issue type/bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
duckdb/duckdb-wasm#2335 ·
Maintainers usually reply within 1 day