bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticated

未关闭 适合新手
#1,484 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@ashwanisingh011 已经在做这个了。

开始于 2026年12月3日。

  • #1485 来自 @ashwanisingh011 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, react

调研方向

阅读 packages/api/src/EmbeddedChatApi.ts 和 packages/react/src/views/EmbeddedChat.js,追踪连接错误如何传递到身份验证状态。检查连接流程中连接、登录和流订阅失败的情况,然后运行相关测试,或为被拒绝的连接添加测试覆盖。完成标准是连接失败时会被拒绝,且不会将用户标记为已通过身份验证。

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

描述

bug
Description:

In packages/api/src/EmbeddedChatApi.ts, _doConnect() catches errors from this.sdk.connection.connect(), this.sdk.account.loginWithToken(), and stream subscriptions, calls this.close(), and never rethrows the error.

Because _doConnect() resolves with undefined instead of rejecting, RCInstance.connect(isChannelPrivate).then(...) in packages/react/src/views/EmbeddedChat.js still executes and sets isUserAuthenticated(true) even though the DDP connection failed and was closed.

Steps to reproduce:
  1. Instantiate EmbeddedChatApi and trigger api.connect() while sdk.connection.connect() or sdk.account.loginWithToken() fails/rejects.
  2. Observe that api.connect() resolves normally instead of rejecting.
  3. In EmbeddedChat.js, .then() runs and marks isUserAuthenticated as true with no active DDP subscriptions.
Expected behavior:

_doConnect() should clean up via await this.close() and rethrow the error so connect() rejects and EmbeddedChat does not mark a failed connection as authenticated.

Actual behavior:

connect() resolves silently and EmbeddedChat logs "Connected to RocketChat ..." and sets isUserAuthenticated(true) on a closed socket.

主要语言
JavaScript
星标
171
派生
421
平均合并
3 天 6 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RocketChat/EmbeddedChat 的其他 Issue

查看 RocketChat/EmbeddedChat 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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