watch task always stopping: No possibility to make it retry after some seconds?
- Dominant language
- JavaScript
- Stars
- 12.2k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
This is especially a problem because it happens when I am typing in the IDE. The issue was also asked on SO but no answers till now: https://stackoverflow.com/questions/57992153/grunt-watch-always-stops-watching-after-fatal-errors-how-to-make-it-retry-af
Within some project I use Grunt for tasks like SASS compilation and so on. Basically it works like a charm, but as long as I am typing within the SASS files obviously sometimes an error occurs as I am not finished.
The watch task of my Gruntfile is like this:
// watch files
watch: {
sass: {
files: ['web/var/static/**/*.scss','web/var/static/lib/**','web/var/static/js/*.js'],
tasks: ['default']
}
},
I start it with `grunt watch` in the cli.
Sample error in Grunt log:
```
Completed in 1.968s at Wed Sep 18 2019 13:43:01 GMT+0200 (Central European Summer Time) - Waiting...
>> File "web/var/static/sass/layout/footer.scss" changed.
Running "sass:dist" (sass) task
Running "autoprefixer:dist" (autoprefixer) task
>> 4 autoprefixed stylesheets created.
Running "cssmin:dist" (cssmin) task
>> 4 files created. 706.54 kB → 598.46 kB
Running "concat:dist" (concat) task
Running "uglify:main" (uglify) task
Done.
Completed in 1.769s at Wed Sep 18 2019 13:43:25 GMT+0200 (Central European Summer Time) - Waiting...
>> File "web/var/static/sass/layout/footer.scss" changed.
Running "sass:dist" (sass) task
Fatal error: Error: property "ul" must be followed by a ':'
on line 52 of web/var/static/sass/layout/footer.scss
from line 13 of web/var/static/sass/main.scss
>> ul
----^
```
I always have to re-run the task if this happens because *grunt stops watching*. That means:
- open the console window
- stop the current task
- start the task again
- change a file
This is really slowing down.
Has anybody had a similar problem? How to make grunt retry automatically after an error as soon as a new file changes happens?
Contributor guide
Research direction
Start with the `grunt watch` entry point and the watch configuration shown in the Gruntfile. Reproduce the Sass syntax error while editing `web/var/static/**/*.scss`, then observe the watcher after the fatal error. Done means a subsequent file change causes the tasks to run again without manually restarting `grunt watch`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100