Skip to content

Commit 9618cbf

Browse files
fix conda env refresh not waiting for promises (microsoft#751)
This was causing the refresh function to return with empty or missing environments before waiting for all async calls that update the env collection. This bug was somehow causing duplicate environments to appear in the list of environments. Co-authored-by: Eleanor Boyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent 4cef397 commit 9618cbf

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/managers/conda/condaUtils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -694,12 +694,14 @@ export async function refreshCondaEnvs(
694694
.filter((e) => e.kind === NativePythonEnvironmentKind.conda);
695695
const collection: PythonEnvironment[] = [];
696696

697-
envs.forEach(async (e) => {
698-
const environment = await nativeToPythonEnv(e, api, manager, log, condaPath, condaPrefixes);
699-
if (environment) {
700-
collection.push(environment);
701-
}
702-
});
697+
await Promise.all(
698+
envs.map(async (e) => {
699+
const environment = await nativeToPythonEnv(e, api, manager, log, condaPath, condaPrefixes);
700+
if (environment) {
701+
collection.push(environment);
702+
}
703+
}),
704+
);
703705

704706
return sortEnvironments(collection);
705707
}

0 commit comments

Comments
 (0)