fix(windows): prevent warp.exe from hanging after window closes#10216
Draft
fix(windows): prevent warp.exe from hanging after window closes#10216
Conversation
When the user closes Warp on Windows, the window hides immediately but `std::process::exit(0)` is only called after `on_will_terminate` returns. `shutdown_all_pty_event_loops` (Windows-only) joins PTY event loop threads with no timeout; if a thread fails to exit the process hangs indefinitely. Add a 5-second timeout to `shutdown_event_loop` on Windows so that a stuck PTY event loop thread never prevents the process from exiting. If the timeout fires, the thread is left to be killed by `std::process::exit(0)`, and the OS will close the ConPTY handle which signals OpenConsole to exit on its own. Also surface mio `Waker::wake()` failures as logged errors instead of silently swallowing them, making it easier to diagnose if wake-up failures are the root cause of a stuck event loop on a given machine. Co-Authored-By: Oz <[email protected]>
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.
Description
Fixes the intermittent bug (#10202) where
warp.exestays alive after the window visually closes on Windows.Root cause
When the user closes Warp, the event loop fires
LoopExiting:hide_app()) — this is the visual close the user seeson_will_terminateruns synchronously —std::process::exit(0)is only called after this returnson_will_terminatecallsshutdown_all_pty_event_loops(), which sendsMessage::Shutdownto each PTY event loop thread and then callsjoin_handle.join()with no timeoutPty::drop()afterconpty_api.close(), or a mioWaker::wake()failure that goes unnoticed — thejoinblocks foreveron_will_terminatenever returns →std::process::exit(0)is never called → process stays alive with no visible windowThe intermittency is explained by the race between ConPTY/OpenConsole teardown timing and whether the pipe read in
Pty::drop()returnsWouldBlockor stalls momentarily.Fix
terminal_manager.rs: Add a 5-second timeout toshutdown_event_loopon Windows. If a PTY event loop thread doesn't exit within the timeout, log a warning and proceed.std::process::exit(0)will kill the remaining thread. The OS will close the ConPTY handle when the process exits, which signals OpenConsole to exit on its own.mio_channel.rs: SurfaceWaker::wake()failures as logged errors instead of silently swallowing them (let _ = waker.wake()). This makes it easier to diagnose whether a Waker failure is causing the event loop to stay blocked inpoll.poll().Linked Issue
Fixes warp.exe process does not terminate reliably #10202
The linked issue is labeled
ready-to-specorready-to-implement.Screenshots / Videos
N/A — internal shutdown timing fix.
Testing
The bug is intermittent and Windows-only, which makes it difficult to add a deterministic automated test. The DEV-channel sleep in
autoupdate/windows.rs(which simulates a slow shutdown) can be used on a Windows dev machine to verify the process now exits promptly.Manual test plan:
warp.exedisappears from Task Manager promptlyAgent Mode
This PR was created by Oz (running Claude Code).