[y-partyserver] Awareness state is not sent to a client that joins an occupied room

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

Chưa có ai nhận issue này.

Đá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
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
distributed-systems

Hướng nghiên cứu

Bắt đầu bằng cách lần theo cách YServer xử lý kết nối và relay awareness, sau đó so sánh hành vi join với server tham chiếu của y-websocket. Tái hiện vấn đề với hai client bằng cách sử dụng disableBc: true và xác minh rằng client kết nối sau nhận được các trạng thái awareness của những client hiện có ngay sau khi kết nối; trạng thái presence không còn được phụ thuộc vào một broadcast awareness diễn ra sau đó.

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

Mô tả

What happens

When a client connects to a YServer room that already has other clients in it, the
newcomer receives the document state but never the awareness state of the
clients that were already connected. It only learns about them once one of them
happens to broadcast an awareness update.

The reverse direction works: the clients that were already connected do receive the
newcomer's awareness as soon as it joins.

The practical symptom is that a presence UI (avatars, remote carets) is empty for
whoever joins last, while everyone else can see them.

Expected

On connect, the server sends the current awareness states of the room to the new
connection, as y-websocket's reference server does — otherwise presence is only
eventually consistent, and only if someone moves.

Reproduction
  1. YServer room with two browser clients, disableBc: true on both so only the
    server relays (with BroadcastChannel on, same-browser tabs mask the problem).
  2. Client A connects and calls awareness.setLocalStateField('user', { … }).
  3. Client B connects some seconds later and does the same.
// Client B, after `status === 'connected'` and after the document has synced:
provider.awareness.getStates()
// → only B's own client id. A is missing.

// Client A at the same moment:
provider.awareness.getStates()
// → both A and B.
Evidence it is specific to awareness

On client B the connection is up and the document arrives over that same socket —
the editor renders the room's content — so this is not a connection or auth problem.
It is only the awareness state that is not replayed.

Workaround

Have each client re-broadcast its own awareness whenever it notices a client id it
has not seen before. It settles after one round, but it means every client needs
this, and presence is briefly wrong before it does.

if (someClientIdIsNew) provider.awareness.setLocalStateField('user', me)
Versions
  • y-partyserver 2.2.0
  • partyserver 0.5.10
  • yjs 13.6.32
  • Durable Objects, SQLite storage, hibernate: true, workerd 1.20260826.1
Ngôn ngữ chính
TypeScript
Star
1.3k
Fork
84
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

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 cloudflare/partykit

Tất cả issue của cloudflare/partykit

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.