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
napi_create_string_utf8 assertion failed #355
Comments
It seems like you're using the old fsevents version. Obviously you're not using it, your dependency is consuming fsevents. So you'll need to find which dependency it is. I've tried installing your test example, but was not able to due to puppeteer. |
Very true, but the error started triggering in the last few days (coinciding with the release of fsevents and chokidar) and I can see fsevents@2.3.1 being used by jest and karma. It appears no other dependency in the tree down to fsevents / chokidar has seen a release in the last couple days. The old version (1.2.13) is 8 months old and so I wouldn't think it's behavior would change so suddenly (maybe environment updates, but doesn't look like the github actions macos environment has changed in the last few days). |
I'm pretty confident though that we've fixed this error in 2.2 |
I was able to get this to work it by downloading fsevents@2.1.3 (ie what's referenced by chokidar@3.4.3) and copying the |
downgrading to |
If someone can create reproducible repo this would help |
Hey @paulmillr,
I am debugging a chokidar issue and tried to access Running the following code on macOS Catalina
Node version: const fsevents = require('fsevents');
fsevents.watch(`${__dirname}/tests`, (path, flags, id) => {
const info = fsevents.getInfo(path, flags, id);
console.log(info)
});
setInterval(() => {
console.log("tick")
}, 60000); I packaged this code in a repo. |
I installed a fresh copy of Node (version I then tried editing No watch events were triggered when editing What is even stranger is that once the file was edited using vim (no watch event triggered), editing that same file in Visual Studio Code no longer triggered watch events. So... clearly something is broken either at the fsevents level or downstream at the macOS level. Unfortunately, I can't debug this deeper as I don't have the required knowledge. I believe this is what is causing issues with chokidar and create-react-app. |
I just created a repo that includes the above code and instructions on how to reproduce this issue. Please let me know if you guys also hit this issue using my experiment. |
I also tried to reproduce the issue with your demo repo.
System: macOS 11.1 (Apple Silicon) |
Thanks for sharing @yss14.
Did you edit the content of |
Big Sur (Apple Silicon), same problem using Nuxt.js, and this one is related to issue nuxt/nuxt#8639 |
@impowski Thanks for the bug report. Have you tried to reproduced the issue using https://github.com/sunknudsen/fsevents-test? |
@sunknudsen yep |
@impowski How many times did you need to edit and save |
@sunknudsen about 39 times |
Hey @pipobscure, Have you tried reproducing the issue using https://github.com/sunknudsen/fsevents-test? Is there any other way I (we) can help? I believe this issue is related to paulmillr/chokidar#1071 and facebook/create-react-app#10475. If so, fixing this bug would have a significant positive impact on my (and many other's) workflow (and mental health). Again, please let me know if I (we) can help. |
Haha, yeah, I'm unable to work normally with my Nuxt.js project, the only way is to kill the server make changes and run it again and do that over and over again, my mental health is clearly in decline right now 😭 |
I've tried |
I've found the reason for the crash. I just don't have a solution yet. It looks like if it doesn't creash (because I seem to be in for a longish night. |
Thanks so much for looking into this issue @pipobscure. ❤️ |
@pipobscure thanks a lot |
Well the long night is over. I have found the issue. The test script has a bug (that also triggers this) sunknudsen/fsevents-test#1 fixes it for the test script/ I have also solved the issue that this triggers and created PR #356 with an explanation of what was going on. TL;DR garbage collection bit me by triggering this and made me hit a missing argument check quite blatantly. |
Hey @pipobscure, Happy to read the long night is over. Looking forward to #356. Is there any chance this PR will solve paulmillr/chokidar#1071 and facebook/create-react-app#10475? Perhaps these upstream issues are not related (I really hope they are). Thanks for fsevents and for helping us out. |
@sunknudsen It's quite possible that this is the same cause. Because if the stop gets garbage collected and stops before another event comes in, then it would indeed just stop watching. I'll have to check chokidar and chat with @paulmillr to see if this may be the cause. |
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 #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 #355
Released as v2.3.2 |
Upgrading Chokidar leads to an upgrade of `fsevents` (i.e. one of Chokidar's own dependencies) which received a fix in v2.3.2 preventing crashes we see in our tests on macOS, especially when run in Github Actions. See fsevents/fsevents#355 for more info.
In the last couple days, my regularly scheduled builds have been failing with:
Failures occur on latest versions of node 10, 12, and 14.
I do not have a minimum reproducible example, but wanted to create an issue to create awareness in case I'm not the only person with this problem. All I can offer right now is this reproduction that uses fsevents through a transitive relation (so may not offer much help).
The text was updated successfully, but these errors were encountered: