Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[y-partyserver] Provider sends other clients' awareness back to the server

オープン 初心者向け
#424 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend

調査の方向性

YProvider の _awarenessUpdateHandler(変更のたびにブロードキャストする awareness 変更ハンドラー)と、provider を origin としてサーバーからの更新を適用する awareness メッセージハンドラーから調べ始めてください。origin が provider の場合は早期 return を追加し、クライアントがサーバーから受け取った更新を再送しないようにします。1 つのタブでカーソルを動かしたときに N 個ではなく 1 フレームだけ送信され、他のタブでリモートカーソルが引き続き描画されれば完了です。サーバー由来の origin の更新をハンドラーがスキップすることを確認するテストがあれば、それを示せます。

索引モデルが issue の本文から書いたものです。

説明

What happens

YProvider's awareness handler sends a message on every awareness change, whatever its origin:

this._awarenessUpdateHandler = ({ added, updated, removed }, _origin) => { /* … */ broadcastMessage(/* … */) };

Awareness updates from the server are applied with the provider as origin (applyAwarenessUpdate(provider.awareness, …, provider) in the awareness message handler), so each client sends every other client's change straight back. YServer already relays every awareness message to all connections, so with N clients one cursor move costs the server N incoming frames instead of 1. On Durable Objects each of them is an invocation: a billed request, and a log event when Workers Logs is on.

Measured

y-partyserver 2.2.0 (the handler is the same on main), 3 Chromium tabs on one document, frames counted by wrapping WebSocket.prototype.send:

Now With the fix below
Cursor move (arrow key) in one tab 3 frames 1
Keystroke, with Tiptap's CollaborationCaret 10 4 (2 with ueberdosis/y-tiptap#55 fixed too)

Remote cursors still render in every tab with the fix.

Suggested fix
this._awarenessUpdateHandler = ({ added, updated, removed }, origin) => {
  if (origin === this) return; // from the server, which has already relayed it to everyone
  // …
};

Every client only needs to receive each awareness update once; re-sending is allowed but not needed (Yjs's author on the same y-websocket behaviour: https://discuss.yjs.dev/t/redundant-messages/1062). Happy to open a PR with a test.

主要言語
TypeScript
スター
1.3k
フォーク
84
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudflare/partykit のほかの issue

cloudflare/partykit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。