Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(view): a failed hosted journey reports Chrome's network [N40]

Corey Olson8a2f7a9e2bd3
diff --git a/test/cockpit/chrome-health.js b/test/cockpit/chrome-health.js
new file mode 100644
index 00000000..4b83e0e2
--- /dev/null
+++ b/test/cockpit/chrome-health.js
@@ -0,0 +1,28 @@
+/**
+ * Chrome's own health beside a failing journey (#902): whether its network service restarted, which empties the
+ * cookie jar, and what Chrome said about it. Only process ids and Chrome's own log lines are kept.
+ */
+import { execFileSync } from 'node:child_process';
+
+/** The pids of this profile's Chrome network service, from the process table; null when the table cannot be read. */
+export function networkServicePids(profile) {
+ try {
+ return execFileSync('ps', ['-axo', 'pid=,command='], { encoding: 'utf8' }).split('\n')
+ .filter((line) => line.includes(profile) && line.includes('NetworkService'))
+ .map((line) => Number(line.trim().split(/\s+/u)[0]));
+ } catch { return null; }
+}
+
+/**
+ * A failure report for one Chrome: its network-service pids when the watched visit began and now (a changed pid is a
+ * restart), and its recent stderr lines about the network service, crashes or restarts.
+ *
+ * @param {{stderr?: () => string}} chrome - The Chrome the journey drove.
+ * @param {string} profile - That Chrome's profile directory, which its child processes name.
+ * @param {number[]|null} atStart - networkServicePids(profile) when the watched visit began.
+ */
+export function chromeHealth(chrome, profile, atStart) {
+ const said = String(chrome?.stderr?.() ?? '').split('\n')
+ .filter((line) => /network ?service|crash|restart/iu.test(line)).slice(-12).map((line) => line.slice(0, 300));
+ return { networkService: { atStart, now: networkServicePids(profile) }, stderr: said };
+}
diff --git a/test/cockpit/fixture.js b/test/cockpit/fixture.js
index 3815228d..5f18a1f9 100644
--- a/test/cockpit/fixture.js
+++ b/test/cockpit/fixture.js
@@ -858,6 +858,7 @@ async function openSnapshotChrome(executable, url, profile, { signal, onOwned }
}
const chrome = await stableChrome({ child, stopped, socket, send, requests, exceptions });
chrome.launchAttempts = launched.launchAttempts;
+ chrome.stderr = launched.stderr;
chrome.startedAt = launched.startedAt;
chrome.close = closeOwned;
await chrome.send('Page.navigate', { url });
diff --git a/test/journeys.test.js b/test/journeys.test.js
index a5c99b8f..d0cfe9a7 100644
--- a/test/journeys.test.js
+++ b/test/journeys.test.js
@@ -12,6 +12,7 @@ import { relayWorkBudgetMs, findChromeExecutable } from './relay-browser-fixture
import { startFixtureChild } from './fixture-child.js';
import { apiStatus } from '../src/api-http.js';
import { NEXT_STEPS } from '../src/next-steps.js';
+import { chromeHealth, networkServicePids } from './cockpit/chrome-health.js';
import { machine, project, startView, fetchLive, openSnapshotChrome, closeSnapshotChrome, press, pickProject, chromeExecutable, boardOf } from './cockpit/fixture.js';
const JOURNEY_HOSTED = 'https://app.pullboard.dev';
@@ -924,6 +925,7 @@ async function everyBoardJourney(t, slow = null) {
let stopRoutes;
let setup;
const cookiePauses = [];
+ let networkAtStart = null;
try {
// A performs one real foreground CLI sign-in and leaves the command waiting at its actual phone enrollment.
const machineFile = join(machineA.env.PULLBOARD_HOME, 'relay-machine/state.json');
@@ -983,6 +985,7 @@ async function everyBoardJourney(t, slow = null) {
await chromeB.waitFor("location.hash === '' && document.querySelector('#chain')?.textContent.includes('linked machine A board')", 45_000); // budget: bounded setup wait within this journey test’s declared outer timeout (5x relay-work budget plus 180 seconds).
await chromeB.send('Page.navigate', { url: 'about:blank' });
journeyTrace.begin();
+ networkAtStart = networkServicePids(profileB);
authTrace.begin();
cookiePauses.length = 0;
// The CI condition: a slow first discovery answer, and from here Chrome's paused requests arrive without cookies (#835).
@@ -1098,6 +1101,9 @@ async function everyBoardJourney(t, slow = null) {
assert.equal(existsSync(keyBFile), false, 'the complete journey creates no relay key for B');
assert.deepEqual(chromeA.exceptions, [], 'A’s real view UI has no browser errors');
assert.deepEqual(chromeB.exceptions, [], 'B’s hosted mixed-board page has no browser errors');
+ } catch (error) {
+ try { t.diagnostic('chrome health ' + JSON.stringify(chromeHealth(chromeB, profileB, networkAtStart))); } catch { /* The original failure remains the test result. */ }
+ throw error;
} finally {
try { await stopRelayAll(setup); }
finally {