Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix: persist Chrome discovery failure and sync latest dev

Buffalo2024d45263dd57f8
diff --cc archify.zip
index d065d928,5a3b9f76..3f02a7b2
Binary files differ
diff --cc archify/bin/finalize.mjs
index 8897045e,d3b39f0f..cec1e73a
--- a/archify/bin/finalize.mjs
+++ b/archify/bin/finalize.mjs
@@@ -14,6 -14,6 +14,7 @@@ import
CAPTURE_VIEWPORTS,
ChromeVisualBrowser,
findChrome,
++ persistBrowserCheckFailure,
VISUAL_CHECK_VIEWPORTS,
} from './visual-check.mjs';
import { startDeliveryUpdateCheck } from './delivery-update.mjs';
@@@ -811,24 -821,13 +812,39 @@@ export async function runFinalize(
const inProcess = stage === 'browser-check' && runBrowserCheck;
let result;
if (inProcess) {
- chromePath = resolveChrome({ env });
- if (chromePath) {
- try {
- const checked = await runBrowserCheck({
- artifactPath: resolvedOutput,
- outDir: resolvedOutDir,
- chromePath,
- resolveChrome: () => chromePath,
- browserFactory,
- });
++ try {
++ chromePath = resolveChrome({ env });
++ if (chromePath) {
+ browser = createBrowser(chromePath, { env });
+ // Retain the startup rejection for the browser gate without emitting
+ // an unhandled rejection before inspect() awaits the same promise.
+ browser.sessionPromise.catch(() => {});
- } catch (error) {
- browserStartupError = error;
+ }
++ } catch (error) {
++ browserStartupError = error;
+ }
- const checked = await runBrowserCheck({
- artifactPath: resolvedOutput,
- outDir: resolvedOutDir,
- chromePath,
- resolveChrome: () => chromePath,
- browserFactory,
- });
++ // Discovery errors have no executable for the browser factory. Record
++ // a failed gate instead of treating them as ordinary Chrome absence.
++ const checked = browserStartupError && !chromePath
++ ? { exitCode: 1, receipt: persistBrowserCheckFailure(resolvedOutput, {
++ schemaVersion: 1, ok: false, command: 'browser-check', status: 'fail',
++ evidenceKind: 'automated-browser', visualReview: 'not-requested',
++ error: browserStartupError.message,
++ diagnostics: [{
++ code: 'viewer/browser-check-runtime', severity: 'error',
++ message: 'browser-check could not discover Chrome.',
++ subject: { artifact: resolvedOutput },
++ evidence: { reason: browserStartupError.message },
++ supportedFixes: ['resolve the reported Chrome discovery error, then rerun browser-check'],
++ }],
++ }, { outDir: resolvedOutDir }) }
++ : await runBrowserCheck({
++ artifactPath: resolvedOutput,
++ outDir: resolvedOutDir,
++ chromePath,
++ resolveChrome: () => chromePath,
++ browserFactory,
++ });
result = { status: checked.exitCode, stdout: JSON.stringify(checked.receipt) };
} else {
result = await runCommand({ stage, cliPath, args, cwd,
diff --cc test/finalize-browser-lifecycle.test.mjs
index b4379966,84d3b3ca..029e98f2
--- a/test/finalize-browser-lifecycle.test.mjs
+++ b/test/finalize-browser-lifecycle.test.mjs
@@@ -296,6 -291,6 +296,35 @@@ test('Chrome startup and discovery fail
}
});
++test('Chrome discovery exceptions persist terminal browser-check and finalize failures', async t => {
++ const { input, output, outDir, source } = inputs(t);
++ let delivered;
++ const finalized = await runFinalize(options({
++ input, output, outDir,
++ resolveChrome: () => { throw new Error('Chrome discovery failed'); },
++ createBrowser: () => { assert.fail('discovery failure must not launch Chrome'); },
++ runBrowserCheck: () => { assert.fail('discovery failure must not inspect Chrome'); },
++ runCommand: ({ stage }) => {
++ if (stage === 'deliver') {
++ delivered = delivery({ input, output, source });
++ return stageResult(delivered);
++ }
++ return stageResult(check(output, delivered));
++ },
++ }));
++ assert.equal(finalized.exitCode, 1);
++ assert.equal(finalized.receipt.status, 'fail');
++ assert.equal(finalized.receipt.failedStage, 'browser-check');
++ assert.equal(finalized.receipt.stages['browser-check'].status, 'fail');
++ const saved = JSON.parse(fs.readFileSync(finalized.receipt.evidence.receipt, 'utf8'));
++ assert.equal(saved.status, 'fail');
++ assert.equal(saved.failedStage, 'browser-check');
++ const browserFailure = JSON.parse(fs.readFileSync(finalized.receipt.evidence.browserCheckReceipt, 'utf8'));
++ assert.equal(browserFailure.status, 'fail');
++ assert.equal(browserFailure.error, 'Chrome discovery failed');
++ assert.equal(browserFailure.diagnostics[0].code, 'viewer/browser-check-runtime');
++});
++
test('finalize closes an unconsumed browser when the in-process browser callback throws', async t => {
const { input, output, outDir, source } = inputs(t);
const events = [];