Skip to content

[BUG] 客户端异常断开时 fencing token 未释放,30 秒内其他 tab 无法获取 controller #16

@pallyoung

Description

@pallyoung

问题描述

packages/server/src/ws/hub.tshandleClose() 在客户端断开时未调用 fencingMgr.release(),导致 fencing token 泄漏。

代码注释称"FencingManager 还没有 releaseByClientId 的方法",但实际上 FencingManager.release(workspaceId, clientId) 已经存在。

复现场景

  1. Tab A 获取 controller 角色
  2. Tab A 网络断开或浏览器崩溃(无法主动调用 fencing.release
  3. 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() 中已有相同的遍历模式可参考。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions