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

Aperta
#1,610 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@officialasishkumar ci sta già lavorando.

Dal 3/11/2026.

  • #1611 di @officialasishkumar — aperta
  • #1615 di @kumar246subham-afk — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
5.2k
Fork
1.9k
Merge medio
1h 4m
PR unite (30g)
2

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/examples

Tutte le issue di vercel/examples

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.