Skip to content

Commit e9c0b30

Browse files
committed
fix(cli): check ignores the cancelled fetch of a proxy-swapped media file, not a broken image
1 parent af098f7 commit e9c0b30

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎packages/cli/src/commands/validate.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ describe("shouldIgnoreRequestFailure", () => {
189189
}
190190
});
191191

192+
it("keeps an aborted image request reportable whatever its file suffix", () => {
193+
for (const ext of ["mkv", "mp4", "png"]) {
194+
const url = `http://127.0.0.1:3000/assets/plate.${ext}`;
195+
expect(shouldIgnoreRequestFailure(url, "net::ERR_ABORTED", "image")).toBe(false);
196+
}
197+
});
198+
192199
it("keeps non-media and non-aborted failures reportable", () => {
193200
expect(
194201
shouldIgnoreRequestFailure("http://127.0.0.1:3000/assets/map.png", "net::ERR_ABORTED"),

‎packages/cli/src/commands/validate.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ interface ContrastEntry {
5151
const CONTRAST_SAMPLES = 5;
5252
const SEEK_SETTLE_MS = 150;
5353
const PREFERRED_SEEK_TARGET_WAIT_MS = 500;
54-
// Containers a proxy swap can abandon mid-fetch; an aborted fetch of one is not a load failure.
54+
// Media files a proxy swap can abandon mid-fetch; an aborted non-image request for one is not a load failure.
5555
const MEDIA_EXTENSIONS =
5656
/\.(3gp|aac|aif|aiff|avi|flac|flv|m2ts|m4a|m4v|mkv|mov|mp3|mp4|mpeg|mpg|mts|mxf|oga|ogg|ogv|opus|wav|weba|webm|wma|wmv)$/i;
5757
// Turn Puppeteer's opaque "Navigation timeout of Nms exceeded" into an
@@ -76,6 +76,7 @@ export function shouldIgnoreRequestFailure(
7676
if (errorText === "net::ERR_ABORTED" && isOptionalCaptionOverridesRequest(url)) return true;
7777
if (errorText !== "net::ERR_ABORTED") return false;
7878
if (resourceType === "media") return true;
79+
if (resourceType === "image") return false;
7980
try {
8081
return MEDIA_EXTENSIONS.test(new URL(url).pathname);
8182
} catch {

‎packages/cli/src/utils/checkBrowser.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,37 @@ describe("keepBrokenImageAborts", () => {
11741174
]);
11751175
});
11761176

1177+
it("reports a still-broken aborted image even when its URL ends in a video suffix", async () => {
1178+
const base = "http://127.0.0.1:3000/assets";
1179+
mountCanvasFixture(`<img id="stuck" src="${base}/plate.mkv">`);
1180+
(document.getElementById("stuck") as HTMLImageElement).decode = () =>
1181+
Promise.reject(new Error("broken"));
1182+
const aborted = (url: string, resourceType: string) => ({
1183+
url: () => url,
1184+
failure: () => ({ errorText: "net::ERR_ABORTED" }),
1185+
resourceType: () => resourceType,
1186+
});
1187+
const page = fakePage();
1188+
page.on = vi.fn((event: string, handler: (request: ReturnType<typeof aborted>) => void) => {
1189+
if (event !== "requestfailed") return;
1190+
handler(aborted(`${base}/plate.mkv`, "image"));
1191+
handler(aborted(`${base}/clip.mkv`, "fetch"));
1192+
});
1193+
installSessionMock(page);
1194+
1195+
const result = await runBrowserCheck(
1196+
PROJECT,
1197+
{ ...DEFAULT_CHECK_OPTIONS, samples: 1, contrast: false },
1198+
{ kind: "none" },
1199+
runAuditGrid,
1200+
);
1201+
1202+
const failed = result.runtimeFindings.filter((finding) => finding.code === "request_failed");
1203+
expect(failed.map((finding) => finding.message)).toEqual([
1204+
"Failed to load assets/plate.mkv: net::ERR_ABORTED",
1205+
]);
1206+
});
1207+
11771208
it("does not report an aborted image whose reload is still pending at the cap", async () => {
11781209
const url = "http://127.0.0.1:3000/assets/slow.png";
11791210
mountCanvasFixture(`<img id="slow" src="${url}">`);

0 commit comments

Comments
 (0)