Skip to content

Commit 83de4ed

Browse files
committed
fix conda env refresh not waiting for promises
this was causing the refresh function to return with empty or missing environments before waiting for all async calls that update the env collection
1 parent 1816c28 commit 83de4ed

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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)