Make the extensions loads in parallel instead of waiting one by one

This commit is contained in:
ncpt 2023-08-19 17:36:13 +07:00 committed by GitHub
parent b80c3276dc
commit 81ccacaa7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1026,18 +1026,21 @@ export class ComfyApp {
}
/**
* Loads all extensions from the API into the window
* Loads all extensions from the API into the window in parallel
*/
async #loadExtensions() {
const extensions = await api.getExtensions();
this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions });
for (const ext of extensions) {
try {
await import(api.apiURL(ext));
} catch (error) {
console.error("Error loading extension", ext, error);
}
}
const extensions = await api.getExtensions();
this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions });
const extensionPromises = extensions.map(async ext => {
try {
await import(api.apiURL(ext));
} catch (error) {
console.error("Error loading extension", ext, error);
}
});
await Promise.all(extensionPromises);
}
/**