fix(watch): don't let a re-raised signal kill the watcher on restart - #36268
Open
minato32 wants to merge 1 commit into
Open
fix(watch): don't let a re-raised signal kill the watcher on restart#36268minato32 wants to merge 1 commit into
minato32 wants to merge 1 commit into
Conversation
On file change the watcher raises a synthetic SIGTERM so JS code can clean up before restarting. A handler that unregisters itself and re-raises a real OS SIGTERM (the signal-exit "unload + re-raise" pattern bundled in Vite 8 / rolldown) then reaches the signal thread with no handler registered, which ran the exit callbacks and the OS default action, killing the watcher instead of restarting it. Add a scoped suppression flag to deno_signals: while set, an unhandled terminating signal (SIGTERM/SIGINT/SIGHUP) is consumed rather than exiting. The watcher enables it around the graceful-restart window (before raising, so the synchronous re-raise is covered). Closes denoland#35942
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.
On file change the watcher raises a synthetic SIGTERM to give JS code a chance to clean up before restarting. If a handler unregisters itself and then re-raises a real OS SIGTERM — the
signal-exit"unload + re-raise" pattern bundled in Vite 8 / rolldown — that real signal reaches the signal thread with no handler registered, so it ran the exit callbacks + the OS default action and terminated the whole watcher instead of restarting it. Any Vite 8 dev server underdeno run --watchdies on the first restart.Fix
Add a scoped suppression flag to
deno_signals. While set, an unhandled terminating signal (SIGTERM/SIGINT/SIGHUP) is consumed instead of running the exit callbacks and the OS default action. The file watcher enables it around the graceful-restart window — set beforeraise(), since the re-raise happens synchronously inside the JS handler — and clears it once the graceful wait is done.Scoped to the restart path only; normal exit and Ctrl+C behavior are unchanged.
Test
run_watch_sigterm_reraise_on_restartintests/integration/watcher_tests.rsreproduces the unload+re-raise pattern withnode:processand asserts the watcher restarts (was: process died).Closes #35942