Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: report incomplete Chrome warm-ups accurately (#9641)

Adam Eivy7a695993426d
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 41897dac70..5f0bae3fbf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -666,9 +666,11 @@ jobs:
# Read the runner's Chrome tree into the page cache before any suite
# launches it (#9641). The recurring startup hang was captured with the
# browser's lead thread waiting on a page-cache read and I/O pressure
- # above 50 right after the installs above, i.e. a cold first launch. The
+ # above 50 right after the installs above, suggesting a cold read. The
# launcher's 20s startup deadline is unchanged; the printed duration shows
- # whether the cold read is as slow as the failures suggest.
+ # whether the cold read is as slow as the failures suggest. Completion
+ # requires every read to succeed within the warm-up budget; a passing
+ # browser run remains a non-reproduction, not proof of a causal repair.
- name: Warm the Chrome install
run: bash scripts/ci-warm-test-chrome.sh
diff --git a/scripts/ci-warm-test-chrome.sh b/scripts/ci-warm-test-chrome.sh
index fab6b9f941..fcb3b0392d 100755
--- a/scripts/ci-warm-test-chrome.sh
+++ b/scripts/ci-warm-test-chrome.sh
@@ -5,14 +5,15 @@
# Why (#9641): the recurring "Test Chrome did not start within 20000ms" failures
# captured the owned child in uninterruptible sleep with its lead thread waiting
# on a page-cache folio (leadWait=page) while the runner's I/O pressure
-# (ioAvg10) was above 50, and no DevToolsActivePort yet. That is the first,
-# cold read of a ~300MB browser tree on a fresh runner that has just written
+# (ioAvg10) was above 50, and no DevToolsActivePort yet. These samples suggest
+# a cold read of the browser tree on a fresh runner that has just written
# ~95 ffmpeg packages and PostgreSQL data. Reading the tree here moves that cost
# out of the 20s startup deadline, which stays unchanged. This is not a retry
# and not a skip; the tests still launch, and must start, the real browser.
#
-# The reported duration is also the evidence: a long warm read confirms the
-# cold page-in mechanism, a short one on a failing run refutes it.
+# Duration is supporting evidence for the cold-read hypothesis, not proof of
+# the startup cause. A failed or partial read must never be reported as warmed;
+# a passing launch after a completed read is still a non-reproduction.
#
# Never fails the job: a missing browser is reported by the suites themselves
# (PORTOS_REQUIRE_BROWSER_SUITES), and the warm read is only an optimisation.
@@ -23,10 +24,16 @@ set -uo pipefail
BUDGET="${CHROME_WARM_BUDGET_SECONDS:-90}"
read -r -a CANDIDATES <<< "${CHROME_WARM_CANDIDATES:-${CHROME_PATH:-} /usr/bin/google-chrome /usr/bin/chromium /usr/bin/chromium-browser}"
-# GNU timeout exists on the Ubuntu runner; elsewhere (a developer's macOS) the
-# read simply runs unbounded, which is still a bounded local directory.
-TIMEOUT=()
-if command -v timeout >/dev/null 2>&1; then TIMEOUT=(timeout --kill-after=5 "$BUDGET"); fi
+# Never replace the wall-clock budget with an unbounded read. GNU coreutils
+# installs timeout as gtimeout on some developer machines.
+if command -v timeout >/dev/null 2>&1; then
+ TIMEOUT=(timeout --kill-after=5 "$BUDGET")
+elif command -v gtimeout >/dev/null 2>&1; then
+ TIMEOUT=(gtimeout --kill-after=5 "$BUDGET")
+else
+ echo "::notice title=Chrome warm-up skipped::No deadline tool is available; the suites will launch the browser cold."
+ exit 0
+fi
# Milliseconds since the epoch. BSD date prints a literal N for %N, so fall back
# to whole seconds there rather than failing the arithmetic.
@@ -41,14 +48,21 @@ now_ms() {
for candidate in "${CANDIDATES[@]}"; do
[ -n "$candidate" ] && [ -e "$candidate" ] || continue
- executable="$(readlink -f "$candidate")"
+ executable="$(readlink -f "$candidate" 2>/dev/null)" || {
+ echo "::warning title=Chrome warm-up incomplete::Cannot resolve the browser install; the suites will launch the browser cold."
+ exit 0
+ }
# The install directory holds the binary, its resources and its libraries.
tree="$(dirname "$executable")"
start="$(now_ms)"
- # cat's exit code is lost behind the pipe, so the byte count is the signal
- # that the read finished and the timeout's 124 is the signal that it did not.
- total="$(mktemp)"
- ${TIMEOUT[@]+"${TIMEOUT[@]}"} bash -c 'find "$1" -type f -print0 | xargs -0 cat 2>/dev/null | wc -c > "$2"' _ "$tree" "$total" 2>/dev/null
+ total="$(mktemp 2>/dev/null)" || {
+ echo "::warning title=Chrome warm-up incomplete::Cannot allocate a byte-count file; the suites will launch the browser cold."
+ exit 0
+ }
+ # pipefail must be enabled in the child shell too: wc can count partial
+ # output successfully even when find or cat failed. Keep all raw errors
+ # private, and report only byte count, duration and pipeline/deadline status.
+ "${TIMEOUT[@]}" bash -o pipefail -c 'find "$1" -type f -print0 | xargs -0 cat 2>/dev/null | wc -c > "$2"' _ "$tree" "$total" 2>/dev/null
status=$?
bytes="$(tr -d '[:space:]' < "$total")"
rm -f "$total"
diff --git a/scripts/ci-warm-test-chrome.test.js b/scripts/ci-warm-test-chrome.test.js
index 3a8fa04bac..41b25a033e 100644
--- a/scripts/ci-warm-test-chrome.test.js
+++ b/scripts/ci-warm-test-chrome.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { mkdtempSync, mkdirSync, writeFileSync, rmSync, symlinkSync, chmodSync } from 'node:fs';
+import { mkdtempSync, mkdirSync, writeFileSync, rmSync, symlinkSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
@@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url';
const script = fileURLToPath(new URL('./ci-warm-test-chrome.sh', import.meta.url));
// Runs the real script against a fake browser tree; nothing reads the host's.
-function run({ layout, budget = '5' }) {
+function run({ layout, budget = '5', failure, timeoutAvailable = true }) {
const dir = mkdtempSync(join(tmpdir(), 'ci-warm-chrome-'));
const install = join(dir, 'opt/chrome');
mkdirSync(install, { recursive: true });
@@ -22,10 +22,23 @@ function run({ layout, budget = '5' }) {
candidates = join(dir, 'google-chrome');
symlinkSync(join(install, 'chrome'), candidates);
}
- if (layout === 'unreadable') chmodSync(join(install, 'chrome'), 0o000);
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ const fake = (name, body) => writeFileSync(join(bin, name), `#!/bin/bash\n${body}\n`, { mode: 0o755 });
+ // Model GNU timeout's interface without sleeping or depending on its presence
+ // on a developer's macOS. The deadline arm returns its actual failure status.
+ if (timeoutAvailable) fake('timeout', failure === 'deadline' ? 'exit 124' : 'shift 2; exec "$@"');
+ if (failure === 'read') fake('cat', 'printf partial; echo "private browser path" >&2; exit 1');
+ if (failure === 'traversal') fake('find', 'printf "%s\\0" "$CHROME_WARM_TEST_FILE"; echo "private browser path" >&2; exit 1');
const result = spawnSync('/bin/bash', [script], {
encoding: 'utf8',
- env: { PATH: process.env.PATH, CHROME_WARM_CANDIDATES: candidates, CHROME_WARM_BUDGET_SECONDS: budget },
+ timeout: 10000, // Fixture subprocess backstop; no production sleeps.
+ env: {
+ PATH: timeoutAvailable ? `${bin}:${process.env.PATH}` : bin,
+ CHROME_WARM_CANDIDATES: candidates,
+ CHROME_WARM_BUDGET_SECONDS: budget,
+ CHROME_WARM_TEST_FILE: join(install, 'chrome'),
+ },
});
rmSync(dir, { recursive: true, force: true });
return result;
@@ -39,6 +52,31 @@ describe.skipIf(process.platform === 'win32')('CI Chrome page-cache warm-up', ()
expect(result.stdout).toMatch(/^🔥 Warmed the Chrome install into the page cache: 4 MiB in \d+ms$/m);
});
+ it.each(['read', 'traversal'])('reports an incomplete warm-up when %s fails after emitting bytes', failure => {
+ const result = run({ layout: 'installed', failure });
+ expect(result.status).toBe(0); // Acceptance still runs; only warm-up is optional.
+ expect(result.stdout).toContain('::warning title=Chrome warm-up incomplete::');
+ expect(result.stdout).not.toContain('Warmed the Chrome install');
+ expect(result.stdout).not.toContain('private browser path');
+ expect(result.stderr).toBe('');
+ });
+
+ it('reports the deadline result without claiming completion or retrying', () => {
+ const result = run({ layout: 'installed', failure: 'deadline' });
+ expect(result.status).toBe(0);
+ expect(result.stdout).toContain('exit 124, budget 5s');
+ expect(result.stdout).not.toContain('Warmed the Chrome install');
+ expect(result.stderr).toBe('');
+ });
+
+ it('leaves the browser cold when a bounded read is unavailable', () => {
+ const result = run({ layout: 'installed', timeoutAvailable: false });
+ expect(result.status).toBe(0);
+ expect(result.stdout).toContain('::notice title=Chrome warm-up skipped::');
+ expect(result.stdout).not.toContain('Warmed the Chrome install');
+ expect(result.stderr).toBe('');
+ });
+
it('never fails the job when no browser exists; the suites report that themselves', () => {
const result = run({ layout: 'missing' });
expect(result.status).toBe(0);