Skip to content

fix: run hangs on child exit#19

Merged
Bechma merged 2 commits into
devfrom
fix/run-hangs
Jul 3, 2026
Merged

fix: run hangs on child exit#19
Bechma merged 2 commits into
devfrom
fix/run-hangs

Conversation

@maurolacy

Copy link
Copy Markdown
Collaborator

No description provided.

maurolacy added 2 commits July 3, 2026 10:25
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>
Signed-off-by: Mauro Lacy <11656534+maurolacy@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a hang in watch mode by unifying file-system watcher events and runner lifecycle notifications onto a single channel, allowing the main loop to react when the child process (or runner thread) terminates.

Changes:

  • Introduces a WatchEvent channel to handle both notify events and child-exit notifications in one event loop.
  • Updates cargo_run_loop to proactively notify the main thread when the child exits (or fails to spawn) so watch mode can stop cleanly.
  • Adds a regression unit test for the spawn-failure case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

enum WatchEvent {
/// A file-system event from the watcher.
Fs(Result<notify::Event, notify::Error>),
/// The child process exited on its own (not killed by a signal).
Comment on lines +242 to 260
#[test]
fn runner_sends_child_exited_on_spawn_failure() {
let (_signal_tx, signal_rx) = mpsc::channel::<RunSignal>();
let (event_tx, event_rx) = mpsc::channel::<WatchEvent>();

// Non-existent directory causes spawn() to fail.
let cargo_dir = PathBuf::from("/nonexistent/cargo/dir");
let config_path = PathBuf::from("/nonexistent/config.yml");

let handle = std::thread::spawn(move || {
cargo_run_loop(&cargo_dir, &config_path, &signal_rx, &event_tx);
});

let event = event_rx
.recv_timeout(Duration::from_secs(5))
.expect("should receive ChildExited within timeout");
assert!(matches!(event, WatchEvent::ChildExited));
handle.join().expect("runner thread should not panic");
}
@Bechma
Bechma merged commit b269352 into dev Jul 3, 2026
2 checks passed
@Bechma
Bechma deleted the fix/run-hangs branch July 3, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants