Fix(cli): recover automatically after browser is closed or crashes#220
Open
Jhoan0714 wants to merge 4 commits into
Open
Fix(cli): recover automatically after browser is closed or crashes#220Jhoan0714 wants to merge 4 commits into
Jhoan0714 wants to merge 4 commits into
Conversation
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.
Summary
This PR fixes #219 the CLI not recovering when the browser is closed manually or crashes externally. Instead of failing with
broken pipeerror, Vibium now detects the dead connection, relaunches the browser, retries the command once, and prints a short notice to the user.Root Cause
ensureBrowser()only checked whetherh.clientwasnil. When the browser process died externally, the daemon kept a stale WebSocket client reference. The failure only surfaced later as a low-level network error:The only workaround was running
vibium stopand retrying manually.Why this matters
Fix
Reactive retry in
Call()— if a command fails with a connection error (broken pipe,closed network connection, etc.), discard the stale state and retry once:isConnectionError()— classifies connection-death errors vs normal app errorsresetBrowserState()— clearsclient,conn, andlaunchResultensureBrowser()lazy-launch path (no changes to individual handlers)User notice via
ToolsCallResult.Notice— optional field so the command result stays clean; CLI prefixes it when present:Validation
Before fix:
After fix:
Note: after rebuilding, restart the daemon (
vibium daemon stop && vibium daemon start) so it loads the new binary.