fix(cli): check ignores the cancelled fetch of a proxy-swapped media file, not a broken image (#6928)

* fix(cli): check ignores the cancelled fetch of a proxy-swapped video in any container

* fix(cli): check ignores the cancelled fetch of a proxy-swapped media file, not a broken image
This commit is contained in:
Miguel Ángel
2026-11-04 00:25:01 +00:00
committed by GitHub
parent f487a20b28
commit e46ecd850e
3 changed files with 50 additions and 1 deletions
@@ -181,6 +181,21 @@ describe("shouldIgnoreRequestFailure", () => {
).toBe(true);
});
it("ignores the aborted fetch of a proxy-swapped source for a listed media suffix", () => {
for (const ext of ["mkv", "m4v", "mts", "m2ts", "avi", "mpg", "MKV"]) {
const url = `http://127.0.0.1:3000/Caf%C3%A9%20%C3%A9t%C3%A9.${ext}`;
expect(shouldIgnoreRequestFailure(url, "net::ERR_ABORTED", "fetch")).toBe(true);
expect(shouldIgnoreRequestFailure(url, "net::ERR_FAILED", "fetch")).toBe(false);
}
});
it("keeps an aborted image request reportable whatever its file suffix", () => {
for (const ext of ["mkv", "mp4", "png"]) {
const url = `http://127.0.0.1:3000/assets/plate.${ext}`;
expect(shouldIgnoreRequestFailure(url, "net::ERR_ABORTED", "image")).toBe(false);
}
});
it("keeps non-media and non-aborted failures reportable", () => {
expect(
shouldIgnoreRequestFailure("http://127.0.0.1:3000/assets/map.png", "net::ERR_ABORTED"),
+4 -1
View File
@@ -51,7 +51,9 @@ interface ContrastEntry {
const CONTRAST_SAMPLES = 5;
const SEEK_SETTLE_MS = 150;
const PREFERRED_SEEK_TARGET_WAIT_MS = 500;
const MEDIA_EXTENSIONS = /\.(aac|flac|m4a|mov|mp3|mp4|oga|ogg|wav|webm)$/i;
// Media files a proxy swap can abandon mid-fetch; an aborted non-image request for one is not a load failure.
const MEDIA_EXTENSIONS =
/\.(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;
// Turn Puppeteer's opaque "Navigation timeout of Nms exceeded" into an
// actionable message: the usual cause is a slow blocking CDN <script>. Returns a
// replacement Error for a navigation timeout, or null for any other error.
@@ -74,6 +76,7 @@ export function shouldIgnoreRequestFailure(
if (errorText === "net::ERR_ABORTED" && isOptionalCaptionOverridesRequest(url)) return true;
if (errorText !== "net::ERR_ABORTED") return false;
if (resourceType === "media") return true;
if (resourceType === "image") return false;
try {
return MEDIA_EXTENSIONS.test(new URL(url).pathname);
} catch {
@@ -1176,6 +1176,37 @@ describe("keepBrokenImageAborts", () => {
]);
});
it("reports a still-broken aborted image even when its URL ends in a video suffix", async () => {
const base = "http://127.0.0.1:3000/assets";
mountCanvasFixture(`<img id="stuck" src="${base}/plate.mkv">`);
(document.getElementById("stuck") as HTMLImageElement).decode = () =>
Promise.reject(new Error("broken"));
const aborted = (url: string, resourceType: string) => ({
url: () => url,
failure: () => ({ errorText: "net::ERR_ABORTED" }),
resourceType: () => resourceType,
});
const page = fakePage();
page.on = vi.fn((event: string, handler: (request: ReturnType<typeof aborted>) => void) => {
if (event !== "requestfailed") return;
handler(aborted(`${base}/plate.mkv`, "image"));
handler(aborted(`${base}/clip.mkv`, "fetch"));
});
installSessionMock(page);
const result = await runBrowserCheck(
PROJECT,
{ ...DEFAULT_CHECK_OPTIONS, samples: 1, contrast: false },
{ kind: "none" },
runAuditGrid,
);
const failed = result.runtimeFindings.filter((finding) => finding.code === "request_failed");
expect(failed.map((finding) => finding.message)).toEqual([
"Failed to load assets/plate.mkv: net::ERR_ABORTED",
]);
});
it("does not report an aborted image whose reload is still pending at the cap", async () => {
const url = "http://127.0.0.1:3000/assets/slow.png";
mountCanvasFixture(`<img id="slow" src="${url}">`);