Skip to content

globalState is not persisted across extension updates #2021

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

Closed
Veetaha opened this issue Aug 28, 2020 · 5 comments
Closed

globalState is not persisted across extension updates #2021

Veetaha opened this issue Aug 28, 2020 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@Veetaha
Copy link

Veetaha commented Aug 28, 2020

Our extension fails to work on code-server (rust-lang/rust-analyzer#5892).
The problem is that we use globalState. We expect the contents of globalState to persist across the extension version updates. Even though this is not mentioned in vscode API docs, but original vscode does persist it, but code-server doesn't.

For example we check for new nightly extension release and record it in globalState like this.
But when we programmatically install the extension from VSIX and reload the window, code-server clears the persistent storage.

Meta

  • Web Browser: Google Chrome Version 84.0.4147.125 (Official Build) (64-bit)
  • Local OS: Ubuntu 20.04.1 LTS
  • Remote OS: (idk, just running code-server on my local PC, so probably same as Local OS)
  • Remote Architecture: x86_64 my PC
  • code-server --version: 3.4.1 48f7c27
@Veetaha Veetaha changed the title globalState doesnt work across extension updates globalState is not persisted across extension updates Aug 28, 2020
@nhooyr nhooyr added the bug Something isn't working label Aug 29, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Aug 29, 2020

cc @code-asher

@code-asher
Copy link
Member

I can replicate with:

await context.globalState.update("key", "value")
vscode.commands.executeCommand("workbench.action.reloadWindow");

I think that (in the web version of VS Code at least) the storage file isn't written to immediately but rather after a delay and reloading for some reason interrupts that delay causing it to never write (further supported by the fact that adding a 1s timeout around the reload makes it work).

Hopefully will be able to track down why the write gets canceled and get it fixed today.

code-asher added a commit that referenced this issue Sep 2, 2020
VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
code-asher added a commit that referenced this issue Sep 2, 2020
VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
code-asher added a commit that referenced this issue Sep 2, 2020
VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
code-asher added a commit that referenced this issue Sep 3, 2020
VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
code-asher added a commit that referenced this issue Sep 3, 2020
VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
@Veetaha
Copy link
Author

Veetaha commented Sep 5, 2020

Should we close this?

@code-asher
Copy link
Member

Recently we've switched to closing the issues once a release with the fix goes out so let's leave it open for now!

@nhooyr nhooyr added this to the v3.6.0 milestone Oct 7, 2020
@code-asher
Copy link
Member

code-asher commented Oct 7, 2020

We recently started using milestones so we can close this now and track whether it's released using the milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants