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

FileSystemProvider gets reinitialized in a completely new JavaScript context #103181

Closed
TomasHubelbauer opened this issue Jul 23, 2020 · 6 comments
Assignees

Comments

@TomasHubelbauer
Copy link
Contributor

  • VSCode Version: 1.47.2 user setup
  • OS Version: Windows 10

Steps to Reproduce:

  1. Clone my extension https://github.com/TomasHubelbauer/vscode-email-viewer and the repository in VS Code
  2. Go to debug by pressing F5
  3. Watch the extension host window pointed to the demo directory appear and select real.eml
  4. Watch a progress indicator appear and go while the email file loads - this populates the cache from cache.ts in extension.js
  5. Watch a new workspace directory appear and list the correct entries (3 PNGs and 1 HTML file) as the cache now has an entry for the parsed contents of the real.eml file selected previously
  6. Wait a bit
  7. Watch a spinner appear next to the already loaded and populated workspace directory node for the real.eml file virtual directory as stat on the FS provider is called again even though it was already called while populating the node initially
  8. Watch an error message pop up because the cache.ts module was reloaded for some reason and this stat call sees {} not the populated cache object which was initialized before when the progress indicator appeared after clicking real.eml
  9. See the debug console in VS Code proper (not the extension host window) and notice the Cache init line appear twice when it should have appeared once because it is in the cache.ts module global context which to me is indicative of a JavaScript context change/reload? (But the window did not reload...)
  10. Be confused

Does this issue occur when all extensions are disabled?: N/A

@jrieken
Copy link
Member

jrieken commented Aug 10, 2020

I am confused. Is this a debugger issue or is this because the extension host restarted after changing the workspace?

@TomasHubelbauer
Copy link
Contributor Author

I have no idea what causes this. Were you able to reproduce?

@jrieken
Copy link
Member

jrieken commented Aug 10, 2020

I am not trying ;-) I know that we don't do anything special for file system providers, esp nothing like creating new JS contexts. So, this can only an issue with debugging and/or when reloading the extension host. Did you try this when bundling and locally installing your extension?

@TomasHubelbauer
Copy link
Contributor Author

I don't think this is related to the extension host reloading, because this happens within the span of a single debugging session. Perhaps it is something with the debugger, but I really couldn't tell you, I have no knowledge of how the VS Code debugger works. I will try to bundle and install locally and report back if that helped. I don't know how to debug this further myself, so if you or anyone else capable of diagnosing this are not going to try and reproduce this, I think that will leave this issue at a dead end.

@TomasHubelbauer
Copy link
Contributor Author

TomasHubelbauer commented Aug 10, 2020

For completeness' sake, when packaging the extension as VSIX and installing it through it, the problem persists: it seems as though the runtime is reloaded from under the extension as it is running. It is as if the module import caused the module to evaluate multiple times (clearing the cache in effect), which AFAIK is not the module loading behavior in either CJS nor ESM.

I still don't know exactly what it is that causes this, but it seems safe to rule out it being a debugger / extension host window issue and instead firmly a runtime issue or an issue with my understanding/assumptions about how the runtime behaves.

@jrieken
Copy link
Member

jrieken commented Aug 10, 2020

Do you see the same with the file system provider sample: https://marketplace.visualstudio.com/items?itemName=jrieken.vscode-memfs?

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants