fix(lint): bound the mermaid browser provisioning and recover from a cut-off install

The chrome-headless-shell download had no time limit, so a stalled
network kept lint-mermaid, and with it the whole quality gate, waiting
for 148 minutes. The install now runs under a 900 second timeout.

An interrupted download leaves the browser folder without its
executable, and puppeteer then refuses every later install of that
build. A failed provisioning therefore clears the puppeteer browser
cache once and tries again before falling back to the existing warning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-21 23:05:21 +02:00
1 parent 0f0492aa59
commit 2f5f52bd1a
1 file changed
+12 -3
+12 -3
View File
@@ -29,9 +29,18 @@ if command -v apt-get >/dev/null 2>&1; then
echo "Warning: apt-get update failed; chrome's shared libs may stay unresolved." >&2
fi
if ! deps_output="$(npx --yes puppeteer browsers install chrome-headless-shell --install-deps 2>&1)"; then
printf 'Warning: chrome-headless-shell provisioning failed; mermaid rendering may fail:\n%s\n' \
"${deps_output}" >&2
provision_browser() {
timeout 900 npx --yes puppeteer browsers install chrome-headless-shell --install-deps 2>&1
}
if ! deps_output="$(provision_browser)"; then
# Exception: a cut-off install leaves a browser folder without its executable, and puppeteer refuses every later install until the cache is cleared.
npx --yes puppeteer browsers clear >/dev/null 2>&1 ||
echo "Warning: clearing the puppeteer browser cache failed." >&2
if ! deps_output="$(provision_browser)"; then
printf 'Warning: chrome-headless-shell provisioning failed; mermaid rendering may fail:\n%s\n' \
"${deps_output}" >&2
fi
fi
workdir="$(mktemp -d)"