AOSSIE-Org / AOSSIE-Org/DebateAI

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

Open
#203 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
84
Forks
198
Avg merge
2d 19h
Merged PRs (30d)
30

Description

### 📌 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.