Skip to content

Watch recursion #53

Closed
Closed

Description

@trsh

So recently I got problems in webpack, where the watcher is spamming "compile" events for files that are updated before watching starts. The rabbit hole was deep, but led me to watchpack.

So:

  1. So at some point doInitialScan is processed in DirectoryWatcher.
  2. This, at least for files, runs setFileTime
  3. As the inital flag is set, this this.files[filePath] = [initial ? Math.min(now, mtime) : now, mtime]; mostly equals to this.files[filePath] = [mtime, mtime];, because the file mtime will be smaller the time now (in case I edited file before running watcher).
  4. Next at some point it gets to process.nextTick and var ts = data[0] === data[1] ? data[0] + FS_ACCURACY : data[0]; and if(ts >= startTime)watcher.emit("change", data[1]);
  5. As this data[0] === data[1] is true (check point 3), FS_ACCURACY is added. So ts is bigger than startTime (delivered from webpack compiler it's self.startTime = Date.now();).
  6. So for aprox 10 seconds (FS_ACCURACY = 10000 milis) it'ss spamming compile events, until the date now reaches file mtime+10 secs.

This doesn't feel right :/

Activity

  1. trsh commented on Jul 18, 2017

    @trsh
    Author

    Any comments?

  2. AlexGalays commented on Jul 25, 2017

    @AlexGalays

    Same as #25
    ?

  3. trsh commented on Jul 25, 2017

    @trsh
    Author
  4. alexander-akait commented on Feb 8, 2018

    @alexander-akait
    Member

    @trsh duplicate #53?

  5. YurySolovyov commented on Feb 8, 2018

    @YurySolovyov

    Adjusting concurrency seems like a crutch, race condition like that should never happen by design.

    If that means things will go slower, it is fine, cause spamming like that confusing and slowing developers anyway.

    Please, dear core team, do not trade speed for correctness and robustness.

  6. sokra commented on Jul 10, 2019

    @sokra
    Member

    closing as it's a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions