webcontainer-core
webcontainer-core copied to clipboard
fs.watch recursive option problem
when trying to use this feature : webcontainerInstance.fs.watch('/src', { recursive: true }, (event, filename) => {
console.log(file: ${filename} action: ${event}
);
});
[ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
I encountered this as well. It means that ava --watch
doesn't work.
Same error here
I am also seeing this error.
This does not do anything when something changes in the directory:
webContainerInstance.fs.watch('/' + pluginData.plugin_dirname, { recursive: true }, (event, filename) => {
console.log(`file: ${filename} action: ${event}`);
});
But this does run the callback function, but only for items in the root of the directory:
webContainerInstance.fs.watch('/' + pluginData.plugin_dirname, {}, (event, filename) => {
console.log(`file: ${filename} action: ${event}`);
});
Hey everyone! :wave:
We landed support for the recursive
flag on the @webcontainer/api
fs.watch
yesterday. :partying_face:
So this means that your examples @johnstonphilip and @dorakadri should no longer report an error saying:
[ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable
on the current platform, which is being used to run Node.js
Note that if you use fs.watch
with the recursive
flag inside a node process you will still get the error as our current version of Node (18.20.3) does not support fs.watch
on Linux (which WebContainer is an approximation of).
So @rotu, to be able to use ava
you'll need to wait until we land Node 20.
@johnstonphilip this seems like a bug. I've created this project: https://stackblitz.com/edit/wc-api-fs-watch, do you think you could fork it and try to reproduce the issue there?
@Nemikolh Thanks! I made a fork here that replicated the bug I am seeing:
https://stackblitz.com/edit/wc-api-fs-watch-hqxlvf?file=main.js
@johnstonphilip, thanks a lot for the reproduction, it helped a lot! :smiley:
This issue should now be resolved. The example you provided works as expected.
I'm going to close this issue, feel free to re-open or open a new one if you run into new issues! Thanks all!