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

オープン
#1,610 コメント 0 件 リアクション 0 件 担当者 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分
マージ済み PR(30日)
2

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/examples のほかの issue

vercel/examples の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。