Skip to content

Some of the get functions are causing a refresh #18755

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
rchiodo opened this issue Mar 22, 2022 · 4 comments · Fixed by #18766
Closed

Some of the get functions are causing a refresh #18755

rchiodo opened this issue Mar 22, 2022 · 4 comments · Fixed by #18766
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug verification-found Issue verification failed verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@rchiodo
Copy link

rchiodo commented Mar 22, 2022

Testing #18727

I had code like so:

const extension = vscode.extensions.getExtension("ms-python.python");
  if (extension) {
    if (!extension.isActive) {
      await extension.activate();
    }
    const api: IExtensionApi & IProposedExtensionAPI =
      extension.exports as IExtensionApi & IProposedExtensionAPI;
    if (api.environment) {
      api.environment.onDidEnvironmentsChanged(
        onEnvironmentsChanged.bind(undefined, api),
        undefined,
        context.subscriptions
      );
      void api.environment.refreshEnvironment();
    }
  }

And a handler like so:

function onEnvironmentsChanged(api: IExtensionApi & IProposedExtensionAPI) {
  api.environment.getActiveEnvironmentPath(undefined).then((a) => {
    api.environment.getEnvironmentPaths().then(async (p) => {
      console.log(
        `Environment list changed. Active is ${JSON.stringify(
          a
        )}. \n${JSON.stringify(p, undefined, " ")}`
      );
      if (p) {
        p.forEach(async (t) => {
          const details = await api.environment.getEnvironmentDetails(t.path);
          console.log(
            `Environment details for ${t.path} are ${JSON.stringify(
              details,
              undefined,
              " "
            )}`
          );
        });
      }
    });
  });
}

This handler is continually called. One of the functions in it is causing a refresh.

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 22, 2022
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug triage area-environments Features relating to handling interpreter environments and removed triage-needed Needs assignment to the proper sub-team labels Mar 23, 2022
@karrtikr karrtikr added needs PR verification-needed Verification of issue is requested and removed triage labels Mar 23, 2022
@karrtikr karrtikr added this to the March 2022 milestone Mar 23, 2022
@karrtikr
Copy link

Should be fixed by #18766

@rchiodo
Copy link
Author

rchiodo commented Mar 23, 2022

I'm still reproing this. Same exact code with the build from here:
https://github.com/microsoft/vscode-python/actions/runs/2030538168

@rchiodo rchiodo reopened this Mar 23, 2022
@rchiodo rchiodo added the verification-found Issue verification failed label Mar 23, 2022
@karrtikr
Copy link

karrtikr commented Mar 24, 2022

I used the same run (v2022.3.2030538168-dev) but unable to repro this. This is my extension sample: https://github.com/microsoft/vscode-extension-samples/tree/kartik/testbranch/helloworld-sample, & my commit of your handler: microsoft/vscode-extension-samples@8aa5dcc

Not sure what might be going on, for me logging stops once the refresh is over. Let's discuss once you're up.

@rchiodo
Copy link
Author

rchiodo commented Mar 24, 2022

Nope I was wrong. Not infinite anymore, just fires a lot.

@rchiodo rchiodo closed this as completed Mar 24, 2022
@rchiodo rchiodo added the verified Verification succeeded label Mar 24, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug verification-found Issue verification failed verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
3 participants