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

FileService dies during execution #13892

Closed
BarryDrez opened this issue Jul 6, 2024 · 12 comments
Closed

FileService dies during execution #13892

BarryDrez opened this issue Jul 6, 2024 · 12 comments
Labels
filesystem issues related to the filesystem 🤔 needs more info issues that require more info from the author

Comments

@BarryDrez
Copy link

I have a Theia extension that has been working perfectly fine with Theia 1.40.0. I recently upgraded to Theia 1.50.1, and the FileService.exists (@theia/filesystem/lib/browser/file-service) is causing my extension to crash without throwing any kind of exception. I went through all of the breaking changes since 1.40.0 and fixed a couple that were required.

Any ideas what this could be? Could there be a dependency I am missing or need to upgrade?

@dipliveweb
Copy link

Hello, Theia team,

I am following up on Barry's query. We are still having the same issue. We would appreciate any suggestions or pointers.

Thank you

@msujew msujew added filesystem issues related to the filesystem 🤔 needs more info issues that require more info from the author labels Jul 15, 2024
@msujew
Copy link
Member

msujew commented Jul 15, 2024

What kind of crash are we talking about here? Does the error crash the whole tab/browser window?

Aside from that, I'm not aware of any breaking changes in that area of Theia. Do you have reproduction steps for the issue?

@BarryDrez
Copy link
Author

BarryDrez commented Jul 15, 2024

@msujew I have an iframe for my JSE extension that I invoke from one of my parent pages outside of Theia. When the following line is executed:
if (await this.fileService.exists(URIofFileInMyWorkspace)) {

The iframe disappears, and throws me back to the parent page.

Nothing in my code has been changed in this area since I upgraded Theia. I did however upgrade to nodejs version 20 from 18.

@BarryDrez
Copy link
Author

BarryDrez commented Jul 23, 2024

@msujew I have traced the problem to file-service.ts: FileService.doReadAsFileStream (line 955).
The error is: "Unable to resolve nonexistent file '/user/tasks.json'"

Any idea what this means?
It runs OK on Windows.

@msujew
Copy link
Member

msujew commented Jul 23, 2024

@BarryDrez I see, thanks. Looking into the code, we do something weird that might cause this error:

https://github.com/eclipse-theia/theia/blob/master/packages/filesystem/src/browser/file-service.ts#L972

Even though it shouldn't happen, there might be cases where a promise rejects before its await is hit and therefore results in an unhandled rejection error - however that should generally lead to an error in the console and not the whole frame crashing.

Nevertheless, vscode does something different there see this code which is a bit safer. A fix for this issue might attempt to do the same.

@BarryDrez
Copy link
Author

BarryDrez commented Jul 23, 2024

@msujew Thank you! I tried removing @theia/task from my package.json since I don't need tasks, but that didn't help.

In the call stack, I can see that the problem stems from theia\packages\preferences\src\browser\abstract-resource-preference-provider.ts: AbstractResourcePreferenceProvider.readPreferencesFromFile Line 154.

const content = await this.fileService.read(this.toFileManager().getConfigUri())

@BarryDrez
Copy link
Author

@msujew Are there any updates on this? Should I apply the fix that you suggest, or is someone else working on it?

@msujew
Copy link
Member

msujew commented Jul 25, 2024

@BarryDrez I don't think anyone else is working on this right now. Feel free to contribute a fix for this :)

@BarryDrez
Copy link
Author

@msujew OK, thanks :) We will look into becoming contributors.

@BarryDrez
Copy link
Author

Hi @msujew, we are still investigating this. It turns out that readFileUnbuffered is not being called in our scenario. The failure is happening in the Theia class:
theia\packages\filesystem\src\common\remote-file-system-provider.ts

In the stat function (line 216). When this.server.stat(resource.toString()); is called, the application just fails with no exception.

Is there anything we need to be aware of with RemoteFileSystemServer as far as upgrading from Theia 1.40 to 1.51 is concerned?

@BarryDrez
Copy link
Author

@msujew - It turned out that the root of the problem was caused when upgrading from 1.40 - 1.52. We have some views that extend AbstractViewContribution. They were importing Widget from '@phosphor/widgets', and they have the withWidget functions. This is what was causing the error, but I do not understand why the problem manifested itself in remote-file-system-provider.ts.

We have changed the views to import Widget from '@theia/core/lib/browser'. This resolved the issue.

You may want to mention this in the relevant Breaking Changes.

@msujew
Copy link
Member

msujew commented Sep 11, 2024

@BarryDrez I'm confused on how a change in the frontend has the ability to literally crash the backend - this generally shouldn't be possible. However, it's good to hear that the issue has been resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem issues related to the filesystem 🤔 needs more info issues that require more info from the author
Projects
None yet
Development

No branches or pull requests

3 participants