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

Secrets store onDidChange does not fire in the window where the update was made in VS Code 1.8.0 #187247

Closed
tomduncalf-figma opened this issue Jul 7, 2023 · 6 comments
Assignees
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded

Comments

@tomduncalf-figma
Copy link

tomduncalf-figma commented Jul 7, 2023

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.80.0 (660393d)
  • OS Version: macOS 12.5.1 (21G83)

Steps to Reproduce:

  1. Create an extension listens for changes in the secrets store and calls console.log when there is a change (for example), using context.secrets.onDidChange.
  2. Update the secrets store, using context.secrets.store

Expected behaviour:

The change listener should fire and the log message will be seen in both the current VS Code window, and any other VS Code windows which are open where the extension is running

Actual behaviour:

In VS Code 1.8.0 (and also Insiders and VS Code built from source from the latest main), the onDidChange listener never fires in the window where the update was made. It does fire in other windows.

In 1.79.2, the listener would fire in the instance where the update was made. It seems the behaviour changed in #185077, specifically the change listener is paused when storing the secret.

It may be that this is a deliberate change, in which case it should be documented, but it seems somewhat surprising/a bit of a regression to me, as now you need to make sure you manually invoke any secret store change handlers in addition to using a listener.

This broke some functionality in our extension which was working in 1.79.2, the workaround is just to call the change handler manually at the point of updating the secret store, but this means you have to remember to do this in multiple places potentially and breaks my expectations around how the listener would work.

Repro:

This example extension provides a minimal repro of the bug: https://github.com/tomduncalf-figma/vscode-insiders-secrets-ondidchange-bug. Running the extension and triggering the "Hello World" command will log Secrets changed in the regular VS Code build, but will not log anything in Insiders.

@tomduncalf-figma tomduncalf-figma changed the title Secrets store onDidChange is not firing on VS Code Insiders Secrets store onDidChange is not firing in VS Code 1.8.0 Jul 7, 2023
@tomduncalf-figma tomduncalf-figma changed the title Secrets store onDidChange is not firing in VS Code 1.8.0 Secrets store onDidChange does not fire in the window where the update was made in VS Code 1.8.0 Jul 7, 2023
@TylerLeonhardt TylerLeonhardt added candidate Issue identified as probable candidate for fixing in the next release bug Issue identified by VS Code Team member as probable bug authentication Issues with the Authentication platform labels Jul 7, 2023
@TylerLeonhardt TylerLeonhardt added this to the June 2023 Recovery 1 milestone Jul 7, 2023
@TylerLeonhardt
Copy link
Member

Thanks for calling this out. I originally did this because you already have the secret you're storing in the window you're storing it in... but this is changed behavior so I'll change it back. We'll also include it in the 1.80 recovery which will be next week.

@tomduncalf-figma
Copy link
Author

Cool, thank you! Yeah, in our case we are doing something in response to the secret changing, so with the current behaviour we have to have both a change listener (for other windows), and a manual call to the listener (for the active window).

@BeFunes
Copy link

BeFunes commented Jul 10, 2023

Hi! We're having the same problem in our extension .
@tomduncalf-figma, could you share what you did to manually call the listener?

@TylerLeonhardt
Copy link
Member

Closing this since the PR is merged and it'll be in 1.80.1

@tomduncalf-figma
Copy link
Author

Hey @BeFunes - I just mean something like:

context.secrets.onDidChange(e => {
  handleSecretsDidChange();
});

function handleSecretsDidChange() {
  // do stuff
}

function somethingWhichUpdatesSecrets() {
  context.secrets.store("whatever", "secret");
  handleSecretsDidChange(); // This won't be necessary after 1.80.1 but for now we need to manually invoke the change listener, otherwise it will never fire for the VS Code window in which the change happened
}

@TylerLeonhardt
Copy link
Member

Verification in Stable candidate:

  • download the zip, unzip it, and install the VSIX:
    secret-storage-issue-verification-0.0.1.vsix.zip
  • open two VS Code windows
  • Run the command Secret Storage Issue Verification: Do the thing
  • You should see a notification in each window saying that a secret changed

in 1.80.0, you would only see it in the window that you didn't run the command in.

@rzhao271 rzhao271 added the verified Verification succeeded label Jul 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants