- Notifications
You must be signed in to change notification settings - Fork471
Refactor CLI to use spawn for better signal handling in watch mode#7844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
pkg-pr-newbot commentedSep 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
rescript@rescript/darwin-arm64@rescript/darwin-x64@rescript/linux-arm64@rescript/linux-x64@rescript/runtime@rescript/win32-x64commit: |
Worked on Windows as well. |
👍 from me, great stuff! But would be good if@cknitt had a look. |
Thanks! I wonder if this logic shouldn't be extracted to some helper function and used in other places, too, like bsc.js or in the rescript legacy code. Actually we already have |
Hmm, I'm not sure really, I’d prefer keeping this in the CLI runtime rather than lib_dev/process.js (which is dev/test-only and has different behavior). bsc.js runs a single-shot compiler invocation without a watch loop. There’s no long-lived child to gracefully tear down on Ctrl+C, so execFileSync is appropriate and simpler. The problem we fixed only shows up in rescript.js because rewatch runs indefinitely and needs orderly signal forwarding/cleanup. The user problem is with rescript.js, fixing it there seems fine to me. |
535a8bd intorescript-lang:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Replaced execFileSync with spawn to prevent blocking the event loop, allowing for proper signal forwarding and cleanup on termination. This change enhances the user experience during watch mode by ensuring that the Rust watcher can exit cleanly and that the parent process does not terminate prematurely. Added signal handling for SIGINT, SIGTERM, SIGHUP, and SIGQUIT to manage child process termination effectively.
This is to prevent the terminal being blocked after sending
ctrl + cduring watch mode.Problem goes away after this PR: