From fc8142b2b9a2125e127a4a1a5934640aceda4e9f Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 25 Sep 2026 23:27:14 +0900 Subject: [PATCH] fix(bootstrap): offer a retry on boot failures a reload can fix (09-10) A config or manifest request that failed or timed out left only an error code on screen. The boot shell now explains and offers a "try again" button for those codes; it never reloads on its own, so the reload-once rule holds. Co-Authored-By: Claude Opus 5.5 --- src/bootstrap/boot.tsx | 4 ++- .../boundaries/boot-error-shell.tsx | 20 +++++++++++ src/presentation/i18n/boot-messages.ts | 4 +++ tests/component/render-boundary.test.tsx | 33 +++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/boot.tsx b/src/bootstrap/boot.tsx index a3a8b8ad..5d4526ee 100644 --- a/src/bootstrap/boot.tsx +++ b/src/bootstrap/boot.tsx @@ -53,7 +53,9 @@ async function boot(): Promise { window.location.reload(); return; } - root.render(); + root.render( + window.location.reload()} />, + ); } } diff --git a/src/presentation/boundaries/boot-error-shell.tsx b/src/presentation/boundaries/boot-error-shell.tsx index e71b4223..97e90da5 100644 --- a/src/presentation/boundaries/boot-error-shell.tsx +++ b/src/presentation/boundaries/boot-error-shell.tsx @@ -4,6 +4,15 @@ import { BOOT_MESSAGES } from "../i18n/boot-messages.ts"; // has to render when the installed feature graph failed to evaluate. const MESSAGES = BOOT_MESSAGES["ko-KR"]; +// 09-10. Failures a fresh load can fix: the config or manifest request did +// not complete. Retrying stays a user action; nothing reloads on its own. +const RETRYABLE_CODES: ReadonlySet = new Set([ + "CONFIG_FETCH_FAILED", + "CONFIG_TIMEOUT", + "MANIFEST_FETCH_FAILED", + "MANIFEST_TIMEOUT", +]); + export type BootErrorShellProps = Readonly<{ kind?: string; code?: string; @@ -12,6 +21,7 @@ export type BootErrorShellProps = Readonly<{ releaseId?: string; invalidKeys?: readonly string[]; supportReference: string; + onRetry?: () => void; }>; export function BootErrorShell({ @@ -23,7 +33,9 @@ export function BootErrorShell({ releaseId, invalidKeys, supportReference, + onRetry, }: BootErrorShellProps) { + const retry = onRetry !== undefined && RETRYABLE_CODES.has(code); return (

{MESSAGES["boot.failure.title"]}

@@ -57,6 +69,14 @@ export function BootErrorShell({ )} + {retry && ( + <> +

{MESSAGES["boot.retry.hint"]}

+ + + )}

{MESSAGES["boot.supportReference"].replace( "{reference}", diff --git a/src/presentation/i18n/boot-messages.ts b/src/presentation/i18n/boot-messages.ts index 269d7c08..b49b75dd 100644 --- a/src/presentation/i18n/boot-messages.ts +++ b/src/presentation/i18n/boot-messages.ts @@ -13,6 +13,8 @@ export const BOOT_MESSAGES = Object.freeze({ "boot.field.configSchema": "설정 스키마", "boot.field.release": "릴리스", "boot.field.invalidKeys": "잘못된 설정 키", + "boot.retry.hint": "네트워크 연결을 확인한 뒤 다시 시도해 주세요.", + "boot.retry.action": "다시 시도", "boot.supportReference": "지원 참조: {reference}", } as const), "en-US": Object.freeze({ @@ -23,6 +25,8 @@ export const BOOT_MESSAGES = Object.freeze({ "boot.field.configSchema": "Configuration schema", "boot.field.release": "Release", "boot.field.invalidKeys": "Invalid configuration keys", + "boot.retry.hint": "Check the network connection and try again.", + "boot.retry.action": "Try again", "boot.supportReference": "Support reference: {reference}", } as const), }); diff --git a/tests/component/render-boundary.test.tsx b/tests/component/render-boundary.test.tsx index 63208a00..812d520f 100644 --- a/tests/component/render-boundary.test.tsx +++ b/tests/component/render-boundary.test.tsx @@ -73,6 +73,39 @@ describe("render recovery boundaries", () => { expect(shell).not.toHaveTextContent("stack"); }); + it.each(["CONFIG_FETCH_FAILED", "CONFIG_TIMEOUT", "MANIFEST_FETCH_FAILED", "MANIFEST_TIMEOUT"])( + "offers a retry for the network failure %s (09-10)", + async (code) => { + const onRetry = vi.fn(); + const user = userEvent.setup(); + render( + , + ); + expect(screen.getByRole("alert")).toHaveTextContent( + "네트워크 연결을 확인한 뒤 다시 시도해 주세요.", + ); + await user.click(screen.getByRole("button", { name: "다시 시도" })); + expect(onRetry).toHaveBeenCalledTimes(1); + }, + ); + + it("offers no retry for a failure a reload cannot fix (09-10)", () => { + render( + {}} + />, + ); + expect(screen.queryByRole("button")).toBeNull(); + }); + it("allows a boundary reset action without reloading the page", async () => { let shouldThrow = true; function Recoverable() {