vscode.workspace.createFileSystemWatcher inconsistent yeoman trigger (debian)

I’m facing an inconsistent behavior of vscode.workspace.createFileSystemWatcher.
Creating files via yeoman generator that match the glob pattern doesn’t always trigger create event.
Sometimes it trigger update event and sometime nothing. Most of the time create event is triggered but not always.
It happens to me on debian.
Are there any known limitations on file watch with multiple updates at once or something like that?

[original thread by amiramw]

@amiramw Could you debug please https://github.com/eclipse-theia/theia/blob/0f7fc561a10357003ce0caa19167e4cac1905578/packages/filesystem/src/node/nsfw-watcher/nsfw-filesystem-watcher.ts#L111-L127

If events are there then it is a bug in the plugin system.

If not then it is either bug in mentioned code or in underlying library: nsfw.

There are some nsfw bugs but they are related to rename events on windows or missing events for symlinks.


Seems it is a bug in nsfw, I think the explorer tree also might not be rerendedered in some cases due to that


i suspect it is the same as this one: https://github.com/Axosoft/nsfw/issues/60

For the explorer it is not the issue, since it refreshes recursively.

For the plugin system we could scan the new directory for sub files and directories after it gets created. I would be concerned about performance and races with following fs events.


Isn’t vs code file watch also based on nsfw on linux? shouldn’t the proper fix be on nsfw?

yes, the best would be the proper fix on nsfw, but the author does not seem to be opened to it: https://github.com/Axosoft/nsfw/issues/60#issuecomment-433118578

@amiramw VS code used to have nsfw on linux as an experimental option, that now looks to have been removed. They use Chokidar: https://github.com/paulmillr/chokidar , which we tried early in Theia but had performance issues-with.

I believe VS Code use nsfw always, especially for multi-root workspaces, chokidar won’t be able to deal with it.

Here is logic which they use to pick the watcher: https://github.com/microsoft/vscode/blob/f367d0fe2067d0603210b0a10ef104bc01449087/src/vs/platform/files/node/diskFileSystemProvider.ts#L532-L554

@anton-kosyakov thanks for the link. Looks like Chokidar is the watcher behind “UnixWatcherService” and like you say nsfw is used for multi-root workspaces. Good to know.