Skip to content

An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.

fix(browser-checks): reject failed page navigation

Rudy Celekli1490df15d66a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bf7b18d..91bc513 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,6 +25,9 @@ jobs:
with:
node-version: 22
+ - name: Navigation regressions
+ run: node --test scripts/navigation.test.mjs
+
- name: Dial indicator
run: |
node examples/dial-indicator/build.mjs
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8152ae2..3e2e261 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha
### Fixed
+- Capture and drive now fail when Chrome cannot load the requested page, instead of reporting a clean browser error page.
+
- `examples/test-rig/` drew its glass button dark in the light theme. `stretch.css` now has light values for its own colours.
### Changed
diff --git a/scripts/capture.mjs b/scripts/capture.mjs
index 755bb0a..c67ecd8 100644
--- a/scripts/capture.mjs
+++ b/scripts/capture.mjs
@@ -163,7 +163,9 @@ async function main() {
if (options.theme) features.push({ name: "prefers-color-scheme", value: options.theme });
if (features.length) await send("Emulation.setEmulatedMedia", { features });
await send("Emulation.setDeviceMetricsOverride", { width: options.width, height: options.height, deviceScaleFactor: options.scale, mobile: options.width < 600 });
- await send("Page.navigate", { url });
+ const navigation = await send("Page.navigate", { url });
+ if (navigation.error) throw new Error(`Navigation failed: ${navigation.error.message}`);
+ if (navigation.result?.errorText) throw new Error(`Navigation failed: ${navigation.result.errorText}`);
await sleep(Math.min(options.wait, 1500));
await evaluate(`(async()=>{const h=document.documentElement.scrollHeight;for(let y=0;y<h;y+=400){scrollTo(0,y);await new Promise(r=>setTimeout(r,60))}scrollTo(0,0)})()`);
await sleep(Math.max(0, options.wait - 1500));
diff --git a/scripts/drive.mjs b/scripts/drive.mjs
index ef2c90b..e6b3859 100644
--- a/scripts/drive.mjs
+++ b/scripts/drive.mjs
@@ -167,7 +167,9 @@ async function main() {
const early = [SLOW, options.noWebgl ? NO_GL : "", options.preload ?? ""].filter(Boolean).join("\n");
await send("Page.addScriptToEvaluateOnNewDocument", { source: early });
await send("Emulation.setDeviceMetricsOverride", { width: options.width, height: options.height, deviceScaleFactor: options.scale, mobile: options.width < 600 });
- await send("Page.navigate", { url });
+ const navigation = await send("Page.navigate", { url });
+ if (navigation.error) throw new Error(`Navigation failed: ${navigation.error.message}`);
+ if (navigation.result?.errorText) throw new Error(`Navigation failed: ${navigation.result.errorText}`);
await sleep(1200);
const boxOf = (selector) => evaluate(`(()=>{const el=document.querySelector(${JSON.stringify(selector ?? ".iso-plate")})||document.body;const r=el.getBoundingClientRect();return {x:r.left,y:r.top,w:r.width,h:r.height,sx:scrollX,sy:scrollY}})()`);
const readout = () => evaluate(`(document.querySelector("[data-readout]")||{}).textContent||""`);
diff --git a/scripts/navigation.test.mjs b/scripts/navigation.test.mjs
new file mode 100644
index 0000000..506f043
--- /dev/null
+++ b/scripts/navigation.test.mjs
@@ -0,0 +1,55 @@
+import assert from "node:assert/strict";
+import { execFile } from "node:child_process";
+import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { createServer } from "node:net";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { promisify } from "node:util";
+import { fileURLToPath } from "node:url";
+import test from "node:test";
+
+const execute = promisify(execFile);
+
+async function run(name, kind) {
+ const directory = await mkdtemp(join(tmpdir(), "anatomy-navigation-"));
+ try {
+ let target = join(directory, "figure.html");
+ if (kind === "valid") await writeFile(target, '<!doctype html><div class="iso-plate" style="width:100px;height:100px">Figure</div>');
+ if (kind === "refused") {
+ const server = createServer();
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
+ target = `http://127.0.0.1:${server.address().port}/`;
+ await new Promise((resolve) => server.close(resolve));
+ }
+ const args = [fileURLToPath(new URL(`${name}.mjs`, import.meta.url)), target, ...(name === "capture" ? ["--out", join(directory, "shot.png"), "--wait", "0"] : ["[]"])];
+ try {
+ return { code: 0, ...await execute(process.execPath, args, { timeout: 30000 }) };
+ } catch (error) {
+ return { code: error.code, stdout: error.stdout, stderr: error.stderr };
+ }
+ } finally {
+ await rm(directory, { recursive: true, force: true });
+ }
+}
+
+for (const name of ["capture", "drive"]) {
+ test(`${name} fails a missing local page`, async () => {
+ const result = await run(name, "missing");
+ assert.equal(result.code, 1);
+ assert.match(result.stderr, /Navigation failed.*ERR_FILE_NOT_FOUND/);
+ assert.doesNotMatch(result.stdout, /console: clean/);
+ });
+
+ test(`${name} fails refused HTTP navigation`, async () => {
+ const result = await run(name, "refused");
+ assert.equal(result.code, 1);
+ assert.match(result.stderr, /Navigation failed.*ERR_CONNECTION_REFUSED/);
+ assert.doesNotMatch(result.stdout, /console: clean/);
+ });
+
+ test(`${name} preserves successful local navigation`, async () => {
+ const result = await run(name, "valid");
+ assert.equal(result.code, 0);
+ assert.match(result.stdout, /console: clean/);
+ });
+}