[next-chat] Typing indicator gets stuck when a socket disconnects mid-typing

未关闭
#1,610 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@officialasishkumar 已经在做这个了。

开始于 2026年11月3日。

  • #1611 来自 @officialasishkumar —— 未关闭
  • #1615 来自 @kumar246subham-afk —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

Start with ChatHub.handleClose in lib/chat/index.ts, which currently ignores typing state, and the typingUsers handling in lib/chatReducer.ts. Reproduce by mounting ChatHub on a plain ws server: one client sends { type: 'typing' } and is terminated, and the other should receive a stop typing frame. Done when a closing typist's peers get a stop typing for that user, and a rejoining client drops typing entries it can no longer trust.

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

描述

Summary

In websockets/next-chat, the "X is typing" indicator can get stuck on other users' screens indefinitely.

There are two paths:

  1. Typist disconnects mid-typing. The client sends typing on the first keystroke and relies on a 900 ms idle timer to send stop typing. If the socket drops before that timer fires (closed tab, network blip, laptop sleep), send() is a no-op on the dead socket, so stop typing is never delivered. ChatHub.handleClose (lib/chat/index.ts) does nothing about typing state, so every peer keeps showing "alice is typing".
    • If the user reconnects within the presence staleness window (PRESENCE_STALE_MS, 20 s by default), no user left frame is broadcast either. That frame is the only other thing that clears typingUsers in lib/chatReducer.ts, so the indicator never clears.
  2. Viewer disconnects while someone stops typing. If a viewer's own socket is down when a peer's stop typing is broadcast, the viewer misses it. After reconnecting, the viewer still shows the stale typing entry, because the login frame sent on rejoin leaves typingUsers unchanged.

Steps to reproduce

  1. Open the chat in two tabs and join as alice and bob.
  2. In alice's tab, start typing, then within ~1 s kill alice's connection (close the tab, or go offline in DevTools and back online).
  3. bob's tab keeps showing "alice is typing". If alice reconnects quickly, it never clears.

I also reproduced this outside the browser by mounting ChatHub on a plain ws server. Two clients join, one sends { type: 'typing' } and is then terminated, and the other client never receives a stop typing frame.

Expected

When a typing socket closes, peers should get a stop typing for that user. A client that rejoins after a disconnect should drop typing state it can no longer trust.

主要语言
TypeScript
星标
5.2k
派生
1.9k
平均合并
1 小时 4 分钟
30 天内合并 PR
2

环境准备

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

从这里开始

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

vercel/examples 的其他 Issue

查看 vercel/examples 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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