AOSSIE-Org / AOSSIE-Org/DebateAI

[Bug] Online Matchmaking Gets Stuck in “Searching” State

未关闭
#203 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
84
派生
198
平均合并
2 天 19 小时
30 天内合并 PR
30

描述

### 📌 Description
When a user joins **Online Matchmaking**, the UI correctly shows the user as being added to the queue and the search timer starts. However, **no match is ever created**, even when compatible players are present or when multiple users join the queue over time.

This results in users being stuck indefinitely in the **“Searching…”** state.

---

### 🔁 Steps to Reproduce
1. Go to **Start Debate → Matchmaking**
2. Click **Find a Debate Partner**
3. Observe:
- Timer starts (`Searching…`)
- User appears under **Players in Queue**
4. Open another browser or incognito window with a different account
5. Join matchmaking again with a compatible Elo range
6. ❌ No match is created; both users remain in the queue

---

### 📷 Screenshot

Image

### ✅ Expected Behavior
- When two compatible users (with overlapping Elo ranges) are present in the queue:
- A debate room should be created automatically
- Both users should be removed from the queue
- Both clients should receive a `match_found` WebSocket event
- Users should be redirected to the debate room

---

### ❌ Actual Behavior
- Users are successfully added to the matchmaking queue
- The search timer continues indefinitely
- No debate room is created
- No `match_found` event is emitted
- Users must manually cancel matchmaking

---

### 🧠 Possible Root Causes
- Matchmaking logic runs **only once on join**, not periodically
- No background worker or loop to continuously check the queue
- Elo range matching condition may be too strict or incorrect
- Matched users are not removed atomically from the queue
- Match creation event is not emitted over WebSocket

---

### 💡 Suggested Fix
- Add a **periodic matchmaking worker** (e.g., every 1 second) to process the queue
- Use **overlapping Elo range matching logic**
- Ensure matched users are removed atomically from the queue
- Emit a `match_found` WebSocket event to both matched users

---

#### 🧪 Environment

- OS: Any
- Browser: Chrome / Firefox
- Frontend: React (Vite)
- Backend: Go
- Matchmaking Mode: Online Matchmaking

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。