Skip to content

Commit e18dfa9

Browse files
MarcoDotIOclaude
andcommitted
fix(server): browser load errors with digits keep their full name
The server browser cut net error names at the first digit, so a page that failed with net::ERR_HTTP2_PROTOCOL_ERROR showed "ERR_HTTP" in the unreachable page, preview_status, and preview_navigate's error. Digits are now part of the name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 96ffd7a commit e18dfa9

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/server/src/preview/ServerBrowserPage.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,17 @@ describe("server browser drag", () => {
287287
}
288288
});
289289
});
290+
291+
describe("server browser net errors", () => {
292+
it.each([
293+
["net::ERR_CONNECTION_REFUSED", "ERR_CONNECTION_REFUSED", -102],
294+
[
295+
"page.goto: net::ERR_HTTP2_PROTOCOL_ERROR at https://localhost:5173/",
296+
"ERR_HTTP2_PROTOCOL_ERROR",
297+
-2,
298+
],
299+
["net::ERR_TLS13_DOWNGRADE_DETECTED", "ERR_TLS13_DOWNGRADE_DETECTED", -2],
300+
])("reads the whole error name from %j", (errorText, description, code) => {
301+
expect(ServerBrowserPage.parseNetError(errorText)).toEqual({ description, code });
302+
});
303+
});

‎apps/server/src/preview/ServerBrowserPage.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ const NET_ERROR_CODES: Readonly<Record<string, number>> = {
918918
};
919919

920920
export const parseNetError = (errorText: string) => {
921-
const description = /ERR_[A-Z_]+/.exec(errorText)?.[0] ?? errorText;
921+
// Names can hold digits, as in ERR_HTTP2_PROTOCOL_ERROR.
922+
const description = /ERR_[A-Z\d_]+/.exec(errorText)?.[0] ?? errorText;
922923
return { description, code: NET_ERROR_CODES[description] ?? -2 };
923924
};
924925

0 commit comments

Comments
 (0)