Pre-launch Chromium on server startup to avoid cold-start blocking

Chromium cold launch takes several seconds and blocks the event
loop, preventing SSE events from flushing. Now the browser is
warmed up during server startup if any store uses render_js,
so the first search doesn't pay the launch penalty.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
mariosemes
2026-03-26 22:42:15 +01:00
parent 80335d213c
commit 0e2e8d1766
2 changed files with 14 additions and 0 deletions

View File

@@ -116,6 +116,12 @@ export async function scrapeStoreWithBrowser(store: Store, searchUrl: string): P
}
}
export async function warmupBrowser(): Promise<void> {
log('Warming up browser...');
await getBrowser();
log('Browser ready');
}
export async function closeBrowser(): Promise<void> {
if (browser) {
await browser.close();