fix(engine): a late image whose URL Node cannot parse no longer stops the render (#8728)

This commit is contained in:
Miguel Ángel
2026-11-24 17:12:13 +00:00
committed by GitHub
parent 90e86ef38a
commit 5969cd2b43
2 changed files with 14 additions and 3 deletions
@@ -30,6 +30,17 @@ describe("describeLateImage", () => {
});
});
// fails without the fix: a host the browser loads but Node's URL parser rejects threw out of the late-image wait
it("describes an image whose URL Node cannot parse as another origin, without throwing", () => {
const src = "https://xn--ab-m1t.com/assets/logo.png";
expect(() => new URL(src)).toThrow();
expect(describeLateImage(src, PAGE, QUEUED)).toMatchObject({
from: "other-origin",
pathDepth: 0,
extension: "",
});
});
it("counts a new connection as connect time, not queue time", () => {
const fresh = { ...QUEUED, connectStart: 1_600, connectEnd: 1_900, requestStart: 1_900 };
const record = describeLateImage(`${PAGE}/assets/logo.svg`, PAGE, fresh);
@@ -49,12 +49,12 @@ export function describeLateImage(
pageOrigin: string,
raw: RawResourceTiming | undefined,
): LateImageRecord {
const url = new URL(src);
const segments = url.pathname.split("/").filter(Boolean);
const url = URL.canParse(src) ? new URL(src) : undefined;
const segments = url?.pathname.split("/").filter(Boolean) ?? [];
const name = segments.at(-1) ?? "";
const dot = name.lastIndexOf(".");
return {
from: url.origin === pageOrigin ? "page-server" : "other-origin",
from: url?.origin === pageOrigin ? "page-server" : "other-origin",
pathDepth: segments.length,
extension: dot > 0 ? name.slice(dot + 1).toLowerCase() : "",
timing: raw ? splitTiming(raw) : "no-entry",