Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/engine/src/services/frameCapture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
formatRequestFailureDiagnostic,
isFontResourceError,
sanitizeDiagnosticUrl,
shouldIgnoreRequestFailureDiagnostic,
} from "./frameCapture.js";

describe("isFontResourceError", () => {
Expand Down Expand Up @@ -221,4 +222,35 @@ describe("navigation diagnostics", () => {
}),
).toBe("[Browser:HTTP403] GET https://cdn.example.com/frame.png resource=image Forbidden");
});

it("ignores benign media aborts without hiding real request failures", () => {
expect(
shouldIgnoreRequestFailureDiagnostic({
resourceType: "media",
url: "http://127.0.0.1:4173/assets/video.mp4",
failureText: "net::ERR_ABORTED",
}),
).toBe(true);
expect(
shouldIgnoreRequestFailureDiagnostic({
resourceType: "other",
url: "http://127.0.0.1:4173/assets/audio.oga?cache=1",
failureText: "net::ERR_ABORTED",
}),
).toBe(true);
expect(
shouldIgnoreRequestFailureDiagnostic({
resourceType: "media",
url: "http://127.0.0.1:4173/assets/video.mp4",
failureText: "net::ERR_FAILED",
}),
).toBe(false);
expect(
shouldIgnoreRequestFailureDiagnostic({
resourceType: "script",
url: "http://127.0.0.1:4173/assets/app.js",
failureText: "net::ERR_ABORTED",
}),
).toBe(false);
});
});
33 changes: 29 additions & 4 deletions packages/engine/src/services/frameCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,27 @@ export function formatRequestFailureDiagnostic(input: {
);
}

/**
* Chromium reports media loads that it intentionally cancels during probing as
* request failures. They are expected when the probe discovers or seeks local
* audio/video and do not indicate a missing asset.
*/
export function shouldIgnoreRequestFailureDiagnostic(input: {
resourceType: string;
url: string;
failureText: string;
}): boolean {
if (input.failureText !== "net::ERR_ABORTED") return false;
if (input.resourceType === "media") return true;
try {
return /\.(?:aac|flac|m4a|mp3|mp4|mov|oga|ogg|ogv|wav|webm)$/i.test(
new URL(input.url).pathname,
);
} catch {
return false;
}
}

export function formatHttpErrorDiagnostic(input: {
method: string;
resourceType: string;
Expand Down Expand Up @@ -1581,16 +1602,20 @@ export async function initializeSession(session: CaptureSession): Promise<void>
});

page.on("requestfailed", (request) => {
if (request.resourceType() === "script") {
const resourceType = request.resourceType();
const url = request.url();
const failureText = request.failure()?.errorText ?? "unknown";
if (resourceType === "script") {
recordScriptLoadFailure(session, request.url());
}
if (shouldIgnoreRequestFailureDiagnostic({ resourceType, url, failureText })) return;
appendBrowserDiagnostic(
session,
formatRequestFailureDiagnostic({
method: request.method(),
resourceType: request.resourceType(),
url: request.url(),
failureText: request.failure()?.errorText ?? "unknown",
resourceType,
url,
failureText,
}),
);
});
Expand Down
Loading