Repository navigation
fix(windows): exit native host on backend disconnect - #17
Merged
sheehanmunim merged 2 commits intoOct 8, 2026
Merged
sheehanmunim merged 2 commits into
sheehanmunim merged 2 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
Fixes #16.
Terminate the Windows native-host relay when its server-to-Chrome reader finishes. Chrome keeps the host's stdin open while its native port exists; returning from the backend reader alone leaves the process blocked in the opposite direction. Chrome never sees native-port disconnect and the extension keeps a stale port.
This adds a Windows-only
std::process::exit(0)at the end of that reader. It covers backend EOF/read failure and Chrome-output failure. Linux and macOS behavior, extension reconnect scheduling, MCP schemas, approval policy and dependencies remain unchanged.Regression and CI
Add
scripts/test-native-host-restart.py, a Python standard-library-only Windows harness using random isolated Win32 named pipes, explicit HANDLE signatures, bounded reads/writes and cleanup. No Chrome, registry or live backend is touched.The four scenarios cover:
The Windows CI job now builds the executable and runs the harness with Python 3.11.
Executed validation
Based on current
main,deb4c7a:cargo test --locked --manifest-path windows-linux/Cargo.toml: 93 passed on Windows.cargo build --locked --manifest-path windows-linux/Cargo.toml: passes.run_native_host, rebuild, rerun: 2/4 pass, backend EOF and restart fail because the host stays alive after three seconds.git diff --check: passes.Earlier validation of the same five-line repair on release
v0.6.0: Windows source tests 92/92; Linux source tests baseline and patched 94/94 each; initialization, all 32 MCP schemas and disconnected response comparison unchanged. Those release-base checks are distinct from the current-main Windows results above. Current-main cross-platform CI has not yet run at submission time.A local native-host-only deployment restored live Chrome list/open/read/close after a one-time retirement of verified stale relays. Chrome automatically launched replacements. No live gateway restart or OS reboot was used as a test. The isolated regression verifies process/transport restart, not the Chrome reconnect scheduler itself.
Risk and scope
Process exit skips destructors and can interrupt an in-flight browser action when the backend disappears. That is preferable to retaining a dead native port. Completed outbound frames are flushed by the existing loop before EOF is observed. Exit is confined to the Windows native-host subprocess; it cannot terminate the MCP/backend process.
No changes to site approvals, desktop fallback, Chrome profiles, or the separate child-tab ownership defect (#14).