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

Aperta
#420 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Inizia tracciando la gestione delle connessioni e del relay di awareness di YServer, quindi confronta il comportamento di join con il server di riferimento di y-websocket. Riproduci il problema con due client usando disableBc: true e verifica che il client che si connette successivamente riceva gli stati di awareness dei client esistenti immediatamente dopo la connessione; lo stato di presenza non dovrebbe più dipendere da un broadcast di awareness successivo.

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

Descrizione

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
Lingua principale
TypeScript
Stelle
1.3k
Fork
84
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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

Tutte le issue di cloudflare/partykit

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.