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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b685b616e4
commit
fc8142b2b9
@@ -53,7 +53,9 @@ async function boot(): Promise<void> {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
root.render(<BootErrorShell {...safe} />);
|
||||
root.render(
|
||||
<BootErrorShell {...safe} onRetry={() => window.location.reload()} />,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string> = 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 (
|
||||
<main role="alert">
|
||||
<h1>{MESSAGES["boot.failure.title"]}</h1>
|
||||
@@ -57,6 +69,14 @@ export function BootErrorShell({
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
{retry && (
|
||||
<>
|
||||
<p>{MESSAGES["boot.retry.hint"]}</p>
|
||||
<button type="button" onClick={onRetry}>
|
||||
{MESSAGES["boot.retry.action"]}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<p>
|
||||
{MESSAGES["boot.supportReference"].replace(
|
||||
"{reference}",
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
|
||||
@@ -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(
|
||||
<BootErrorShell
|
||||
kind="BOOT_CONFIG_FAILURE"
|
||||
code={code}
|
||||
supportReference={`build-a:${code}`}
|
||||
onRetry={onRetry}
|
||||
/>,
|
||||
);
|
||||
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(
|
||||
<BootErrorShell
|
||||
kind="BOOT_CONFIG_FAILURE"
|
||||
code="CONFIG_SCHEMA_INVALID"
|
||||
supportReference="build-a:CONFIG_SCHEMA_INVALID"
|
||||
onRetry={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByRole("button")).toBeNull();
|
||||
});
|
||||
|
||||
it("allows a boundary reset action without reloading the page", async () => {
|
||||
let shouldThrow = true;
|
||||
function Recoverable() {
|
||||
|
||||
Reference in New Issue
Block a user