From 69e40f106ffcce45066b40abb4f1f5ea9ea1b374 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 25 Sep 2026 23:25:24 +0900 Subject: [PATCH] fix(bootstrap): report unexpected boot errors without a console call (09-04) check:diagnostics refuses direct console use in src. The development report of an unclassified boot error now goes through reportError, which still lands in the browser console. Co-Authored-By: Claude Opus 5.5 --- src/bootstrap/render-boot-failure.tsx | 7 ++++--- tests/component/boot-unexpected-failure.test.tsx | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/render-boot-failure.tsx b/src/bootstrap/render-boot-failure.tsx index 26e75e56..b25fe0ee 100644 --- a/src/bootstrap/render-boot-failure.tsx +++ b/src/bootstrap/render-boot-failure.tsx @@ -12,11 +12,12 @@ const ERROR_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9]{0,39}$/u; /** * 09-04. A boot failure no loader classified: an assembly defect, a module * that threw while evaluating. It is shown as such, with the build and the - * error's class name, never its message; a development build also logs the - * original error, which is otherwise lost. + * error's class name, never its message; a development build also reports + * the original error to the console (`reportError`; direct console calls are + * refused by check:diagnostics), where it was otherwise lost. */ export function unexpectedBootFailure(error: unknown): BootErrorShellProps { - if (import.meta.env.DEV) console.error(error); + if (import.meta.env.DEV) globalThis.reportError?.(error); const { buildId } = getBuildConfig(); const name = error instanceof Error ? error.name : ""; const code = ERROR_NAME_PATTERN.test(name) ? name : "UNKNOWN_ERROR"; diff --git a/tests/component/boot-unexpected-failure.test.tsx b/tests/component/boot-unexpected-failure.test.tsx index 70b08b9f..f8c2503b 100644 --- a/tests/component/boot-unexpected-failure.test.tsx +++ b/tests/component/boot-unexpected-failure.test.tsx @@ -17,10 +17,12 @@ vi.mock("../../src/bootstrap/create-runtime-composition.ts", () => ({ })); describe("unexpected boot failure (09-04)", () => { - it("is shown as BOOT_UNEXPECTED_FAILURE and keeps the error in the dev console", async () => { + it("is shown as BOOT_UNEXPECTED_FAILURE and reports the error in development", async () => { document.body.innerHTML = '
불러오는 중
'; - const consoleError = vi.spyOn(console, "error").mockImplementation(() => {}); + // jsdom has no reportError; browsers do. + const reportError = vi.fn<(error: unknown) => void>(); + vi.stubGlobal("reportError", reportError); await import("../../src/bootstrap/main.tsx"); @@ -30,7 +32,7 @@ describe("unexpected boot failure (09-04)", () => { expect(shell).toHaveTextContent("local-build"); expect(shell).toHaveTextContent("TypeError"); expect(shell).not.toHaveTextContent("reading 'get'"); - expect(consoleError).toHaveBeenCalledWith(assemblyDefect); + expect(reportError).toHaveBeenCalledWith(assemblyDefect); }); it("lists the rejected configuration keys", () => {