Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent change on add in node watcher #86

Merged
merged 2 commits into from
Feb 13, 2017

Conversation

xdissent
Copy link
Contributor

Turns change events into add events if the add event hasn't yet been emitted. Fixes #75.

@amasad
Copy link
Owner

amasad commented Feb 13, 2017

This should never happen since we filter change events on dirs here.

Any idea how to reproduce this locally? I wasn't able to.

@xdissent
Copy link
Contributor Author

If you clone the pr branch and git checkout origin/master -- src/node_watcher.js the test should fail in linux. I pushed a docker image you can run with docker run --rm xdissent/sane:pr-86. Here's the dockerfile:

FROM node:7-alpine
RUN apk add --update git
WORKDIR /sane
RUN git clone -b bug/change-on-add https://github.com/xdissent/sane.git . && \
  git checkout origin/master -- src/node_watcher.js && \
  npm i -s --unsafe-perm
CMD ["npm", "test"]

@amasad
Copy link
Owner

amasad commented Feb 13, 2017

@xdissent thanks for the dockerfile. Very convenient. So I misunderstood that the change event is triggered on the directory. In this case can we just ignore the change event. No need to debounce the add event again. I'll leave an inline comment.

@@ -317,6 +317,11 @@ NodeWatcher.prototype.processChange = function(dir, event, file) {

NodeWatcher.prototype.emitEvent = function(type, file, stat) {
var key = type + '-' + file;
var addKey = ADD_EVENT + '-' + file;
if (type === CHANGE_EVENT && this.changeTimers[addKey]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return from here. And add a comment to say something like:

// Ignore the change event that is immediately fired after an add event.
// (This happens on Linux).

@amasad amasad merged commit d702d0a into amasad:master Feb 13, 2017
@amasad
Copy link
Owner

amasad commented Feb 16, 2017

should we do a release soon or do you have other things in the works/needs addressing for watchpack? /cc @wtgtybhertgeghgtwtg

@wtgtybhertgeghgtwtg
Copy link
Collaborator

If it's a minor release, I don't have any complaints. I'd like to get #90 in, but it's breaking/not vital.

amasad added a commit that referenced this pull request Feb 21, 2017
@amasad
Copy link
Owner

amasad commented Feb 21, 2017

published 1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants