From e18dfa97e14240223bf464ff7e0228460fe0d385 Mon Sep 17 00:00:00 2001 From: MarcoDotIO Date: Fri, 23 Oct 2026 18:34:41 -0400 Subject: [PATCH] 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 --- apps/server/src/preview/ServerBrowserPage.test.ts | 14 ++++++++++++++ apps/server/src/preview/ServerBrowserPage.ts | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/server/src/preview/ServerBrowserPage.test.ts b/apps/server/src/preview/ServerBrowserPage.test.ts index 2491e6ac9a5fc..aa311a4b51e12 100644 --- a/apps/server/src/preview/ServerBrowserPage.test.ts +++ b/apps/server/src/preview/ServerBrowserPage.test.ts @@ -287,3 +287,17 @@ describe("server browser drag", () => { } }); }); + +describe("server browser net errors", () => { + it.each([ + ["net::ERR_CONNECTION_REFUSED", "ERR_CONNECTION_REFUSED", -102], + [ + "page.goto: net::ERR_HTTP2_PROTOCOL_ERROR at https://localhost:5173/", + "ERR_HTTP2_PROTOCOL_ERROR", + -2, + ], + ["net::ERR_TLS13_DOWNGRADE_DETECTED", "ERR_TLS13_DOWNGRADE_DETECTED", -2], + ])("reads the whole error name from %j", (errorText, description, code) => { + expect(ServerBrowserPage.parseNetError(errorText)).toEqual({ description, code }); + }); +}); diff --git a/apps/server/src/preview/ServerBrowserPage.ts b/apps/server/src/preview/ServerBrowserPage.ts index 02089cca3205c..8e454d22060c5 100644 --- a/apps/server/src/preview/ServerBrowserPage.ts +++ b/apps/server/src/preview/ServerBrowserPage.ts @@ -918,7 +918,8 @@ const NET_ERROR_CODES: Readonly> = { }; export const parseNetError = (errorText: string) => { - const description = /ERR_[A-Z_]+/.exec(errorText)?.[0] ?? errorText; + // Names can hold digits, as in ERR_HTTP2_PROTOCOL_ERROR. + const description = /ERR_[A-Z\d_]+/.exec(errorText)?.[0] ?? errorText; return { description, code: NET_ERROR_CODES[description] ?? -2 }; };