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

Đang mở
#1,610 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@officialasishkumar đang làm issue này rồi.

Từ ngày 3/11/2026.

  • #1611 của @officialasishkumar — đang mở
  • #1615 của @kumar246subham-afk — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
5.2k
Fork
1.9k
Merge trung bình
1 giờ 4 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vercel/examples

Tất cả issue của vercel/examples

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.