From 281a7eb2e14aa6b98d0d104f1bdf7dbcbc05d2c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 May 2026 17:37:39 +0000 Subject: [PATCH 1/2] Handle missing browser libs during prerender --- scripts/prerender.mjs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/scripts/prerender.mjs b/scripts/prerender.mjs index 492360d9..bd767907 100644 --- a/scripts/prerender.mjs +++ b/scripts/prerender.mjs @@ -80,16 +80,42 @@ const routes = [ { path: '/login', file: 'login/index.html' }, ]; +function hasMissingBrowserRuntime(error) { + const message = String(error?.message || error || ''); + return ( + message.includes('Failed to launch the browser process') && + (message.includes('Error loading shared library') || message.includes('symbol not found')) + ); +} + async function prerender() { + if (process.env.SKIP_PRERENDER === '1') { + console.log('SKIP_PRERENDER=1, skipping prerender step.'); + return; + } + console.log('Starting prerender server...'); await new Promise((resolve) => server.listen(port, resolve)); console.log(`Server running at http://localhost:${port}`); - const browser = await puppeteer.launch({ - headless: 'new', - args: ['--no-sandbox', '--disable-setuid-sandbox'], - }); + const strictPrerender = process.env.PRERENDER_STRICT === '1'; + let browser; + + try { + browser = await puppeteer.launch({ + headless: 'new', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + }); + } catch (error) { + server.close(); + if (!strictPrerender && hasMissingBrowserRuntime(error)) { + console.warn('\nSkipping prerender: browser runtime dependencies are unavailable in this build environment.'); + console.warn('Set PRERENDER_STRICT=1 to fail the build instead.'); + return; + } + throw error; + } try { for (const route of routes) { @@ -148,4 +174,3 @@ prerender().catch((err) => { server.close(); process.exit(1); }); - From 7d3f891389776448ba6d2fa55b902a37505503a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 May 2026 17:38:52 +0000 Subject: [PATCH 2/2] Improve prerender launch-failure detection and guidance --- scripts/prerender.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/prerender.mjs b/scripts/prerender.mjs index bd767907..c3a88ecf 100644 --- a/scripts/prerender.mjs +++ b/scripts/prerender.mjs @@ -82,9 +82,13 @@ const routes = [ function hasMissingBrowserRuntime(error) { const message = String(error?.message || error || ''); + const normalized = message.toLowerCase(); return ( - message.includes('Failed to launch the browser process') && - (message.includes('Error loading shared library') || message.includes('symbol not found')) + normalized.includes('failed to launch the browser process') && + (normalized.includes('error loading shared library') || + normalized.includes('error while loading shared libraries') || + normalized.includes('cannot open shared object file') || + normalized.includes('symbol not found')) ); } @@ -111,6 +115,7 @@ async function prerender() { server.close(); if (!strictPrerender && hasMissingBrowserRuntime(error)) { console.warn('\nSkipping prerender: browser runtime dependencies are unavailable in this build environment.'); + console.warn('Install required Chromium/Puppeteer system libraries (for example, libnss3/libatk/libx11) to enable prerendering.'); console.warn('Set PRERENDER_STRICT=1 to fail the build instead.'); return; }