From 5c5794287bd0dc2c94f238ca89f4752ecaa045a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sun, 1 Nov 2026 21:52:04 +0000 Subject: [PATCH] fix(cli): say a font or image URL is a download, not a page, when capture is given one (#6952) * fix(cli): say a font or image URL is a download, not a page, when capture is given one * fix(cli): word the capture download hint as a likely cause, not a fact --- packages/cli/src/capture/navigateForCapture.test.ts | 11 +++++++++++ packages/cli/src/capture/navigateForCapture.ts | 2 ++ 2 files changed, 13 insertions(+) diff --git a/packages/cli/src/capture/navigateForCapture.test.ts b/packages/cli/src/capture/navigateForCapture.test.ts index 167defa0ab..9e0284982c 100644 --- a/packages/cli/src/capture/navigateForCapture.test.ts +++ b/packages/cli/src/capture/navigateForCapture.test.ts @@ -545,6 +545,17 @@ describe("a proxy that was in the way", () => { ); }); + it("tells a file URL apart from a page when the browser turns it into a download", async () => { + const goto = vi + .fn() + .mockRejectedValue(new Error("net::ERR_ABORTED at https://cdn.example/arabic.woff2")); + await expect( + navigateForCapture({ goto }, "https://cdn.example/arabic.woff2", 120_000), + ).rejects.toThrow( + /cdn\.example stopped loading as a page.*file download such as a font.*assets\/fonts.*net::ERR_ABORTED/, + ); + }); + it("leaves every other failure as it was", async () => { const name = new Error("net::ERR_NAME_NOT_RESOLVED at https://nope.example/"); expect(explainProxyRefusal(name, "https://nope.example/")).toBe(name); diff --git a/packages/cli/src/capture/navigateForCapture.ts b/packages/cli/src/capture/navigateForCapture.ts index 318be38e4b..d6fae78f07 100644 --- a/packages/cli/src/capture/navigateForCapture.ts +++ b/packages/cli/src/capture/navigateForCapture.ts @@ -16,6 +16,8 @@ const PROXY_FAILURES = { `Your network's proxy refused the connection to ${host}. Ask whoever runs it to allow ${host}.`, "net::ERR_PROXY_CONNECTION_FAILED": () => "Could not reach your network's proxy. Check the proxy address and that the proxy is running, or ask whoever runs it.", + "net::ERR_ABORTED": (host: string) => + `${host} stopped loading as a page. This usually means the URL is a file download such as a font, not a web page. Capture a page that uses the file; its fonts are saved to assets/fonts.`, } as const; const PROXY_FAILURE = new RegExp(Object.keys(PROXY_FAILURES).join("|"));