-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: incorrect Web API localStorage and sessionStorage behavior in Theia webview #13092
Comments
The webview's iframe src url has a default pattern like this: |
@jfaltermeier Interesting. Do you know if VS Code's URL for the webview's iframe is significantly different, such that it doesn't suffer from this problem? |
@jfaltermeier Yeah, I saw that too. However, it is not so easy to work around that. VS Code is using URLs in the form of, based on the GLSP example extension: With |
Yes, between restarts and reopens it looks like this:
So the hostname is static |
* add optional viewId to WebviewWidgetIdentifier, which may be used to create stable hostnames for webviews * use this viewId to store a uuid which will be used as part of the stable hostname
Bug Description:
Using
window.localStorage
andwindow.sessionStorage
from a vscode extension Webview in Theia doesn't behave as expected--not compared to how it works in VS Code.Data stored in
sessionStorage
survives a number of things in VS Code:Data stored in
localStorage
survives all those things plus it survives an app restart. I.e., the data is stored to disk.In Theia, neither storage behaves how it does in VS Code. Both forms only survive the view being hidden and reshown.
Steps to Reproduce:
Increment Counters
a few timesIncrement Counters
and notice that both counters got reset. They now have a value of 1. This is the bug.In VS Code, the counters would not have reset. In fact, even if you CTRL-R (refresh the VS Code app), the counters don't reset.
If you close VS Code altogether, relaunch it, bring up the view and click
Increment Counters
, you would see thatsessionStorage
was reset, which is expected.localStorage
is not reset as that data is apparently being saved to disk. And that is why there are two forms of storage. One of them stores to the filesystem; the other just to RAM.You can see this in vscode as follows:
Launch the app from vscode and repeat the steps described above for Theia.
Additional Information
The text was updated successfully, but these errors were encountered: