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

Fix unwatch and some sporadic test errors #355

Merged
merged 5 commits into from
Sep 18, 2015
Merged

Fix unwatch and some sporadic test errors #355

merged 5 commits into from
Sep 18, 2015

Conversation

es128
Copy link
Collaborator

@es128 es128 commented Sep 18, 2015

Resolves #273
Resolves #258

When unwatch falls back to setting the paths to be ignored, need to ensure the paths are absolute since that's how the relevant objects are keyed.

Tweaked the tests to better cover the relative path scenarios as well as address a handful of other issues that caused sporadic failures on Travis.

paulmillr added a commit that referenced this pull request Sep 18, 2015
Fix unwatch and some sporadic test errors
@paulmillr paulmillr merged commit 4085f59 into master Sep 18, 2015
@es128 es128 deleted the fix-unwatch branch September 18, 2015 06:43
@rfossella
Copy link

What's the best way to get these changes. I used npm install chokidar to initially install

Thank you

@es128
Copy link
Collaborator Author

es128 commented Sep 18, 2015

I intend to publish to npm today. But if you'd like to try it out early and provide feedback before I do so, that would be great. To install the latest code from the master branch it's simply

npm i paulmillr/chokidar

taratatach pushed a commit to taratatach/chokidar that referenced this pull request Oct 2, 2023
The `napi_external` that maintains the watch on a file is closured into the *stop* function returned by `fsevents.watch`.
When that `napi_external` is garbage collected, the callback that was passed in is released and becomes uncallable. When it is called depsite this, the `napi_env` that is passed in is `NULL` which is intended by N-API as a signal  that the function is no longer usable. 

I ignored it in the past, because I always retain the stop function. However a test-script like the one provided provokes this. When garbage collection happens, the `napi_external` is cleared. However there may still be events in the pipeline. And that in turn triggers the crash in paulmillr#355 .

I am now handling the `napi_env` as `NULL` signal properly by just dropping the event. In consequence, if you do not retain the *stop* function event reporting simply stops. And this will happen fairly quickly.

fixes paulmillr#355
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.

None yet

3 participants