diff --git a/src/tools/browser.ts b/src/tools/browser.ts index 8dd4530c68..9c90b928ba 100644 --- a/src/tools/browser.ts +++ b/src/tools/browser.ts @@ -93,6 +93,7 @@ export async function preparePage(page: playwright.Page) { setInterval(() => { window.onerror = console.error; window.onunhandledrejection = console.error; + (window as any).wppForceMainLoad = true; }, 500); }); diff --git a/src/webpack/index.ts b/src/webpack/index.ts index b1f842c339..aad6f9f5f2 100644 --- a/src/webpack/index.ts +++ b/src/webpack/index.ts @@ -89,7 +89,11 @@ export function injectLoader(): void { debug('injected'); await internalEv.emitAsync('webpack.injected').catch(() => null); - await new Promise((resolve) => setTimeout(resolve, 1000)); + if ((window as any).wppForceMainLoad) { + await new Promise((resolve) => setTimeout(resolve, 5000)); + } else { + await internalEv.waitFor('conn.main_loaded'); + } const allRuntimes = new Array(10000) .fill(1)