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

VSCode extension FileSystemWatcher not working since 1.33.0 #12260

Closed
sgraband opened this issue Mar 6, 2023 · 0 comments · Fixed by #12264
Closed

VSCode extension FileSystemWatcher not working since 1.33.0 #12260

sgraband opened this issue Mar 6, 2023 · 0 comments · Fixed by #12264
Assignees
Labels
file-watchers issues related to filesystem watchers - nsfw vscode issues related to VSCode compatibility

Comments

@sgraband
Copy link
Contributor

sgraband commented Mar 6, 2023

Bug Description:

Extensions that use the vscode.workspace.createFileSystemWatcher function stopped working with Theia 1.33.0. I was able to narrow it down to this commit.

Feel free to assign this ticket to me as i will investigate it and work on a fix.

Steps to Reproduce:

  1. Install the following extension: file-watching-sample-0.0.1.zip
  2. Change/Add/Delete a file
  3. When using Theia 1.32.0 the file watcher detects the change. But when using 1.33.0 it is no longer detected.

Additional Information

  • Operating System: Ubuntu 20.04
  • Theia Version: 1.33.0

Test extension code:

export function activate(context: vscode.ExtensionContext) {
	const watcher = vscode.workspace.createFileSystemWatcher(`**/*`, false, false, false);
	context.subscriptions.push(watcher);
	context.subscriptions.push(watcher.onDidCreate(handleFileCreate));
	context.subscriptions.push(watcher.onDidChange(handleFileChange));
	context.subscriptions.push(watcher.onDidDelete(handleFileDelete));
}

function handleFileCreate(uri: vscode.Uri): void {
	console.log(`file created: ${uri.fsPath}`);
	vscode.window.showInformationMessage(`file created: ${uri.fsPath}`);
}

function handleFileChange(uri: vscode.Uri): void {
	console.log(`file changed: ${uri.fsPath}`);
	vscode.window.showInformationMessage(`file changed: ${uri.fsPath}`);
}

function handleFileDelete(uri: vscode.Uri): void {
	console.log(`file deleted: ${uri.fsPath}`);
	vscode.window.showInformationMessage(`file deleted: ${uri.fsPath}`);
}

Another extension that has the same problem is the eclipse-cdt-cloud clangd-context extension.

@vince-fugnitto vince-fugnitto added vscode issues related to VSCode compatibility file-watchers issues related to filesystem watchers - nsfw labels Mar 6, 2023
sgraband added a commit to eclipsesource/theia that referenced this issue Mar 7, 2023
Fixed an issue with tracking the current `FileSystemEvents`
in the `MainFileSystemEventService`.
Before, the events were tracked in a global field which was intended to
be cleaned after an `onDidFilesChanges()` update was sent to the proxy.
This is problematic as we do not await sending the update.
Thus, the global field will be cleaned before the update is even sent
and therefore, file watching updates might get lost.
This change ensures that a field of events is kept for each update.

Note that simply awaiting the update to be sent is not enough.
This would introduce race conditions as other parallel updates might
clean the state of other updates before they are being sent.

Fixes eclipse-theia#12260.

Contributed on behalf of STMicroelectronics
tsmaeder pushed a commit that referenced this issue Mar 10, 2023
Fixed an issue with tracking the current `FileSystemEvents`
in the `MainFileSystemEventService`.
Before, the events were tracked in a global field which was intended to
be cleaned after an `onDidFilesChanges()` update was sent to the proxy.
This is problematic as we do not await sending the update.
Thus, the global field will be cleaned before the update is even sent
and therefore, file watching updates might get lost.
This change ensures that a field of events is kept for each update.

Note that simply awaiting the update to be sent is not enough.
This would introduce race conditions as other parallel updates might
clean the state of other updates before they are being sent.

Fixes #12260.

Contributed on behalf of STMicroelectronics
martin-fleck-at added a commit to CrossBreezeNL/crossmodel that referenced this issue Mar 17, 2023
- Add support for 'package.json' files
-- Listen to changes of 'package.json' files
-- Add VS code plugins to support editing 'package.json' files

- Add package manager for simple dependency management
-- Do not build 'package.json' files (as they do not match CM grammar)
-- Instead build up dependency graph based on package information
-- Consider models under 'package.json' directory part of the package

- Replace workspace-based scoping with package-based scoping
-- Only models within the same models or dependent models are visible
-- Ensure 'node_modules' directory is also scanned

Minor:
- Update to latest version of Langium
- Convert model service to shared service
-- Requires retrieval of serializer based on URI
-- Extend language model service to ensure we have serializer
- Fix eclipse-theia/theia#12260 locally

TODO:
- Requires reload after npm install (file watching issue?)
tsmaeder pushed a commit that referenced this issue Mar 20, 2023
Fixed an issue with tracking the current `FileSystemEvents`
in the `MainFileSystemEventService`.
Before, the events were tracked in a global field which was intended to
be cleaned after an `onDidFilesChanges()` update was sent to the proxy.
This is problematic as we do not await sending the update.
Thus, the global field will be cleaned before the update is even sent
and therefore, file watching updates might get lost.
This change ensures that a field of events is kept for each update.

Note that simply awaiting the update to be sent is not enough.
This would introduce race conditions as other parallel updates might
clean the state of other updates before they are being sent.

Fixes #12260.

Contributed on behalf of STMicroelectronics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
file-watchers issues related to filesystem watchers - nsfw vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants