fix: wait_until がループ中に最新テレメトリを取得できず timeout する不具合を修正 - #105
Open
TomokiMochizuki wants to merge 1 commit into
Open
fix: wait_until がループ中に最新テレメトリを取得できず timeout する不具合を修正#105TomokiMochizuki wants to merge 1 commit into
TomokiMochizuki wants to merge 1 commit into
Conversation
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.
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.
概要
コマンドプラン(.ops)の制御命令
wait_untilが、実行中に最新テレメトリを取得できず、条件が満たされないまま timeout で失敗する不具合を修正します。根本原因
wait_untilはPlanTabPanel.tsxのexecuteControlRequest内で、whileループ +await _sleep(1000)によりテレメトリをポーリングします。値取得はgetVariableValue→getLatestTelemetries(selector)を経由しますが、このselectorはで render 時点に束縛された Redux state のスナップショットです。
実行を開始した非同期ループはこの
selectorを古いクロージャとして掴み続けるため、websocket 経由でテレメトリが更新され再 render が起きても、ループ内の参照は更新されません。結果として最新値が反映されず、条件が永遠に成立せず timeout していました。修正内容
PlanTabPanel.tsx:react-reduxのuseStoreで安定した 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](範囲比較)でも最新テレメトリで判定されること