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

Abierto
#1,610 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@officialasishkumar ya está trabajando en esto.

Desde el 3/11/2026.

  • #1611 de @officialasishkumar — abierto
  • #1615 de @kumar246subham-afk — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
5.2k
Forks
1.9k
Merge medio
1 h 4 min
PR fusionados (30 d)
2

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel/examples

Todos los issues de vercel/examples

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.