问题描述
packages/server/src/ws/hub.ts 的 handleClose() 在客户端断开时未调用 fencingMgr.release(),导致 fencing token 泄漏。
代码注释称"FencingManager 还没有 releaseByClientId 的方法",但实际上 FencingManager.release(workspaceId, clientId) 已经存在。
复现场景
- Tab A 获取 controller 角色
- Tab A 网络断开或浏览器崩溃(无法主动调用
fencing.release)
- Tab B 在约 30 秒内无法获取 controller 角色
相关代码
|
} |
|
|
|
/** |
|
* Takeover: Force close existing writer and accept new one |
|
* DEPRECATED: This is now handled through fencing.takeover command |
|
* Kept for backward compatibility |
|
*/ |
|
async takeover(newClient: WsClient): Promise<void> { |
|
// Note: This method is deprecated in favor of FencingManager |
修复建议
在 handleClose() 中遍历 fencingMgr.tokens,释放该 clientId 持有的所有 token。FencingManager.cleanup() 中已有相同的遍历模式可参考。
问题描述
packages/server/src/ws/hub.ts的handleClose()在客户端断开时未调用fencingMgr.release(),导致 fencing token 泄漏。代码注释称"FencingManager 还没有 releaseByClientId 的方法",但实际上
FencingManager.release(workspaceId, clientId)已经存在。复现场景
fencing.release)相关代码
coder-studio/packages/server/src/ws/hub.ts
Lines 234 to 242 in 490e555
修复建议
在
handleClose()中遍历fencingMgr.tokens,释放该 clientId 持有的所有 token。FencingManager.cleanup()中已有相同的遍历模式可参考。