Skip to content

Commit

Permalink
Wait for preload scripts before loading renderers (microsoft#164406)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored and formigoni committed Oct 27, 2022
1 parent 3dce1d5 commit 82dfa96
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -1320,13 +1320,15 @@ async function webviewPreloads(ctx: PreloadContext) {

/** Inner function cached in the _loadPromise(). */
private async _load(): Promise<rendererApi.RendererApi | undefined> {
// Preloads need to be loaded before loading renderers.
await kernelPreloads.waitForAllCurrent();

const module: RendererModule = await __import(this.data.entrypoint.path);
if (!module) {
return;
}

this._api = await module.activate(this.createRendererContext());

// Load all renderers that extend this renderer
await Promise.all(
ctx.rendererData
Expand Down Expand Up @@ -1380,7 +1382,7 @@ async function webviewPreloads(ctx: PreloadContext) {
* Returns a promise that waits for all currently-registered preloads to
* activate before resolving.
*/
private waitForAllCurrent() {
public waitForAllCurrent() {
return Promise.all([...this.preloads.values()].map(p => p.catch(err => err)));
}
};
Expand Down

0 comments on commit 82dfa96

Please sign in to comment.