Skip to content

Commit

Permalink
fix: Keep watching local changes after suspension
Browse files Browse the repository at this point in the history
  We wanted to stop watching local changes with Chokidar when macOS goes
  to sleep and restart when resuming but it appears the `unwatch`/`add`
  duo of Chokidar methods does not work as expected (i.e. they at least
  don't seem to be recursive).

  This was preventing the local watcher from doing its job after macOS
  resumed from sleep so we'll try not to stop watching the local changes
  when going to sleep.
  If this has advert effects on the suspension we'll try to find another
  way.
  • Loading branch information
taratatach committed Jan 14, 2025
1 parent 59b2db1 commit 10cd391
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions core/local/chokidar/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ class LocalWatcher {
async resume() {
log.info('Resuming watcher...')

if (this.watcher && this.watcher.getWatched().length === 0) {
this.watcher.add('.')
}

// Flush previously buffered events
this.buffer.flush()
// Restart flushes loop
Expand All @@ -242,11 +238,6 @@ class LocalWatcher {

// Stop flushes loop but keep buffered events
this.buffer.switchMode('idle')

// Stop underlying Chokidar watcher
if (this.watcher) {
this.watcher.unwatch('.')
}
}

async stop(force /*: ?bool */ = false) {
Expand Down

0 comments on commit 10cd391

Please sign in to comment.