question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

au run --watch not picking up changes

See original GitHub issue

I’m submitting a bug report

  • Library Version: 0.30.0

Please tell us about your environment:

  • Operating System: Windows 10

  • Node Version: 6.11.0

  • NPM Version: 5.0.3

  • Browser: n/a

  • Language: TypeScript

Behavior: au run --watch periodically stops seeing changes. I noticed this particularly with .html files, and more-so in the deepest folder paths. Unfortunately reproduction of this issue is not reliable. I have done a lot of console.log in various libraries and believe I have a cause.

The underlying watcher library chokidar (v1.7.0) has a cache of watched directories stored in this._watched and accessed via this._getWatchedDir in index.js line 467. When handling a directory (nodefs-handler.js _handleDir) it calls the above on line 352: var previous = this._getWatchedDir(wh.path);. After an async readdirp it uses that variable at line 373: previous.has(item). If that returns true then the condition which recurses the directories (via _addToNodeFs()) is skipped. If the same folder is traversed by multiple root watches, then that call may retrieve the directory information generated when starting from a different root, and thus a later traversal will skip the folder.

I believe this explains the intermittentness and why it seemed worse at deeper paths: there is an async time delay between reading previous and using it and the probability of the path already being read increases over time. It would also explain why mostly html but occasionally ts files were affect, but scss files were not: html and ts files share directories.

The solution to this is to create one watcher object per glob rather than pass all of them together as occurs in watch.ts:

return gulpWatch(
    Object.keys(watches),
    {
      read: false, // performance optimization: do not read actual file contents
      verbose: true
    },

The globs from Object.keys(watches) are passed via gulpWatch to chokidar.watch, creating only one instance of chokidar.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JeroenVinkecommented, Jul 5, 2017

Also, @winterlimelight thanks for getting to the bottom of this!

0reactions
JeroenVinkecommented, Aug 21, 2017

Nice. Thanks for reporting back @winterlimelight

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aurelia au run --watch... not watching - Stack Overflow
It does not work. My changes are not reflecting in the running website. In the shell prompt where it is watching, nothing happened....
Read more >
Heart health notifications on your Apple Watch
You can enable notifications from the Heart Rate app on your Apple Watch to alert you to high or low heart rates and...
Read more >
[5.4] npm run watch not working - Laracasts
Using 5.4 and mix, when I run npm run watch it compiles once and looks like it is waiting for changes, but when...
Read more >
Frequently asked questions about Google Pixel Watch
Do you have questions about your Google Pixel Watch? Check below for answers or browse the Google Pixel Watch Help Center. Which features...
Read more >
Fitbit Sense User Manual
Set up Sense with the Fitbit app for iPhones and iPads or Android phones. ... your watch, not doing so reduces the potential...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found