fix: 初回接続失敗を再接続ループに委ねて無音恒久化を防ぐ#29
Merged
Merged
Conversation
connect() は初回ハンドシェイク失敗で Err を返すだけで、再接続ループは 一度セッションが確立した connection_task 内にしか存在しなかった。 起動直後のネットワーク未確立などで初回だけ失敗すると、再試行の責務が 宙に浮き「永久にストリームなし」になっていた (notedeck#506 で顕在化 した無音恒久化の構造側)。 初回失敗時も connection_task を spawn し、既存の Equal Jitter バック オフループに最初から任せる。接続の生死は stream-status イベント (connected / reconnecting) でフロントへ伝わる。
旧テストは cmd channel の生存しか見ておらず、「ループに入らず return する」ミューテーションでも通ってしまう vacuous なものだった。 ChannelEmitter で reconnecting の 2 回目 (= ループ冒頭の emit) を待つ 形にし、ミューテーション注入で FAILED になることを確認済み。
フロントは復帰時にリスナーを張り直してから connect を呼び直すが、 既存接続への冪等 return は status を emit しないため、背景化中に 取り逃した状態遷移を補正できず、JS 側が「resolve = connected」と 楽観的に見なすロジックを持たざるを得なかった (初回失敗を Err に しなくなったことでこの楽観が誤りになる)。ConnectionHandle に実状態の AtomicBool を持たせ、冪等 return 時に connected / reconnecting を 正しく emit する。フロントは status イベントだけを信じればよくなる。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
hitalin/notedeck#506 の精査で特定した構造欠陥の notecli 側。connect() の初回ハンドシェイク失敗は Err を返すのみで、再接続ループは一度確立した connection_task 内にしか存在せず、「起動直後のネットワーク未確立 = 永久にストリームなし」が起きうる (PR #28 の本文で別 PR 対応と明記していたもの)。
変更
検証
🤖 Generated with Claude Code