Skip to content

fix: wait_until がループ中に最新テレメトリを取得できず timeout する不具合を修正 - #105

Open
TomokiMochizuki wants to merge 1 commit into
developfrom
fix/wait-until-stale-telemetry
Open

fix: wait_until がループ中に最新テレメトリを取得できず timeout する不具合を修正#105
TomokiMochizuki wants to merge 1 commit into
developfrom
fix/wait-until-stale-telemetry

Conversation

@TomokiMochizuki

Copy link
Copy Markdown
Member

概要

コマンドプラン(.ops)の制御命令 wait_until が、実行中に最新テレメトリを取得できず、条件が満たされないまま timeout で失敗する不具合を修正します。

根本原因

wait_untilPlanTabPanel.tsxexecuteControlRequest 内で、while ループ + await _sleep(1000) によりテレメトリをポーリングします。値取得は getVariableValuegetLatestTelemetries(selector) を経由しますが、この selector

const selector = useSelector((state: RootState) => state);

render 時点に束縛された Redux state のスナップショットです。

実行を開始した非同期ループはこの selector古いクロージャとして掴み続けるため、websocket 経由でテレメトリが更新され再 render が起きても、ループ内の参照は更新されません。結果として最新値が反映されず、条件が永遠に成立せず timeout していました。

修正内容

PlanTabPanel.tsx:

  • react-reduxuseStore安定した store 参照を取得。
  • getVariableValue 内のテレメトリ取得を getLatestTelemetries(selector)getLatestTelemetries(store.getState()) に変更。

store.getState() はレンダリングのタイミングに依存せず、呼び出しの都度必ず最新の state を返すため、ループの各周回で live なテレメトリを観測できるようになります。

getVariableValue 内で stale になり得る参照はこの1箇所のみ(tlmCmdConfig は静的設定)。この変更により wait_until に加え、check_value / get も最新テレメトリを参照するようになります。

テスト計画

  • dotnet build / react-scripts build(publish)が成功すること
  • wait_until <tlm> == <value> を含む .ops プランを実行し、テレメトリ更新で条件成立時にループが timeout せずに抜けること
  • wait_until ... -timeoutsec N で、条件不成立時に指定秒数で正しく timeout すること
  • wait_until <tlm> in [lower, upper](範囲比較)でも最新テレメトリで判定されること

本ループの更新はライブテレメトリ + websocket に依存するため自動テストが難しく、実機/実プランでの動作確認を最終検証とします。

wait_until polls telemetry inside a while loop that spans `await _sleep`,
but getVariableValue read telemetry via getLatestTelemetries(selector),
where `selector` is a Redux state snapshot frozen at render time. The
running async loop kept a stale closure over that snapshot, so websocket
telemetry updates were never observed and the condition could never be
met, causing the command to fail on timeout.

Fetch a stable store reference with useStore() and read fresh state with
store.getState() on each poll, so the loop observes live telemetry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant