[BUG]: Singleton state leak in matchmaking tests causes non-deterministic failures
维护者通常 1 天内回复
评估
调研方向
阅读 backend/services/matchmaking_test.go,并将其清理模式与 backend/services/matchmaking_pool_test.go 进行比较。运行 issue 的 go test 命令以复现共享池计数,然后确保每个测试都删除它添加的所有用户。重复运行均通过,且没有遗留用户影响池大小断言,即为完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 107
- 派生
- 263
- 平均合并
- 7 小时 54 分钟
- 30 天内合并 PR
- 12
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AOSSIE-Org/DebateAI 的其他 Issue
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument page未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/DebateAI#801 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Live Debate Rooms page overflows horizontally on mobile screens可能已有人在做 @SYED-IRTEZA-HUSSAIN-RIZVI 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 66/100
AOSSIE-Org/DebateAI#797 · 4 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
AOSSIE-Org/DebateAI#784 · 4 条评论 ·
维护者通常 1 天内回复
-
[BUG]: Coach Service Updates Non-Existent Field (total_points vs score)可能重新可做 @Basharkhan7776 于 22 天前认领,目前没有进行中的 PR。 未关闭bug
难度 1/5 1 小时以内 新手友好度 85/100
AOSSIE-Org/DebateAI#773 · 2 条评论 ·
维护者通常 1 天内回复
-
[BUG]: IDOR : Missing Ownership Check in ConcedeDebate可能重新可做 @Basharkhan7776 于 22 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
AOSSIE-Org/DebateAI#772 · 1 条评论 ·
维护者通常 1 天内回复
查看 AOSSIE-Org/DebateAI 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
open-webui/tether#52 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
voidzero-dev/void#835 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
AykutSarac/jsoncrack.com#616 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
melgarafael/DeskcommCRM#4679 ·
维护者通常 1 天内回复