Rescue from Interrupt
in tailwindcss:watch
#336
Merged
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.
When sending a SIGINT to end the
rake tailwindcss:watch
(or, for modern Procfile-based Rails applications,bin/dev
) task, Ruby processes this via anInterrupt
exception that can be rescued to handle gracefully tearing the process down. Thetailwindcss:watch
task, however, does not handle this exception, so when the task (or Rails' server viabin/dev
) is terminated via the standard practice of using^C
, that exception propagates and causestailwindcss:watch
toexit 1
. For some (including myself), it's also resulting in a large backtrace; this can erroneously lead developers to think something is wrong.This patch fixes #318 by rescuing
Interrupt
exceptions, which I've verified in my own applications that use this gem. It didn't seem like there's any necessary teardown that needs to happen upon quitting the process, so I left therescue
clause blank except for a log line when in verbose mode. I'm happy to make any necessary changes there, however! Additionally, if thatrescue
should occur elsewhere (e.g. directly inexe/tailwindcss
), I'm happy to move it there (I wasn't sure if that's where it belonged, as the other commands aren't meant to run indefinitely until killed).