AOSSIE-Org / AOSSIE-Org/DebateAI

[BUG]: Self-deadlock in handleRoleSelection hangs the WebSocket connection on every role pick

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

描述

### Bug Description

`handleRoleSelection` in `backend/websocket/websocket.go` locks `room.Mutex` (lines 668–669) and keeps it locked until the function returns using `defer`. While the lock is still held, it calls `snapshotRecipients` (line 678) and `broadcastParticipants` (line 684). Both of these helpers try to acquire the same `room.Mutex` again (lines 108–110 and 191).

Since `sync.Mutex` isn't reentrant, the second `Lock()` call blocks forever, resulting in a deadlock.

### Impact

As soon as a user selects a role in an online debate room, the goroutine handling that WebSocket connection gets stuck. Because the mutex is never released, other operations that need the same room lock can also end up blocked.

### Suggested Fix

Unlock `room.Mutex` before calling `snapshotRecipients` and `broadcastParticipants`, or refactor those helpers to work with an already-locked room (for example, by introducing `snapshotRecipientsLocked`).

### Steps to Reproduce

1. Open an online debate room with two users.
2. Select a role (For/Against).
3. The client stops receiving WebSocket messages, and the backend goroutine deadlocks (can be confirmed with a `SIGQUIT` goroutine dump).

### Logs and Screenshots

_No response_

### Environment Details

_No response_

### Impact

High - Major feature is broken

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

贡献指南

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

调研方向

Start in backend/websocket/websocket.go at handleRoleSelection and trace the calls to snapshotRecipients and broadcastParticipants named in the issue. Reproduce role selection with two users and use a SIGQUIT goroutine dump if needed. Done means selecting a role no longer deadlocks and the client continues receiving WebSocket messages.

由索引模型根据 Issue 内容生成。

评估

技术栈
go
领域
backend, networking
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
78/100

把新 issue 发到你的邮箱

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