Fix execute hang in remote mode#89
Draft
andrii-i wants to merge 3 commits into
Draft
Conversation
2 tasks
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.
Fixes #87
Problem
nb executein remote mode can hang indefinitely. Thetokio::select!in the kernel message loop waits for WebSocket messages and Y.js updates but has no timeout arm. The per-cell deadline is only applied afterStatus(Idle)arrives. If that message is missed (race condition observed afternb output clear+nb executein quick succession), the loop blocks forever.A secondary issue: when the kernel WebSocket closes,
recv_message()returnsOk(None). Theif let Some(msg)pattern silently skipsNone, re-enters the loop, and spins at 100% CPU since a closed socket returnsNoneimmediately on every read.Changes
Added timeout arm to
tokio::select!.sleep_until(deadline)now serves as a select branch so the loop always exits within the configured per-cell timeout, regardless of whetherStatus(Idle)arrives. Matches the same pattern the local executor already uses (timeout_atwrapping each recv).Fixed WebSocket close handling. Changed
if let Some(msg)tomatchwith an explicitNone => breakarm. On WS close the loop now exits into the fallback path instead of spinning.Improved fallback path to collect outputs. Previously the fallback returned a blind
ExecutionResult::success. Now it reads any remaining outputs from the Y.js document and usesfrom_outputsto detect errors, so a timed-out execution that produced an error still reports as failed.Extracted
ExecutionResult::from_outputshelper. Moved the error-detection scan (previously inlined in the happy path) into a reusable method onExecutionResult. Single-passfind_mapover outputs replaces the priorany()+find_map()double scan.