paperclipai/paperclip · error
)`}
Error message
${payload?.error ?? `Failed to request restart (${res.status})`} What it means
The health API's requestDevServerRestart throws this Error when the POST to /api/health/dev-server/restart returns non-OK. It mirrors the other health error paths: prefer the server's `error` string, fall back to a status-embedded message, and consult tenant session recovery first.
Solutions
- Confirm the app is running in dev mode where the restart route exists
- Check server logs for the restart handler's error
- Retry after the dev server has fully started
- Handle non-JSON responses so the fallback status message is shown
Example fix
// before
throw new Error(payload?.error ?? `Failed to request restart (${res.status})`);
// after
if (res.status === 404) throw new Error('Dev-server restart is only available in development mode.');
throw new Error(payload?.error ?? `Failed to request restart (${res.status})`); Defensive patterns
Strategy: fallback
Validate before calling
const isDev = import.meta.env.DEV; if (!isDev) return; // restart route only exists in dev
Type guard
function isRestartError(p: unknown): p is { error: string } { return typeof p === 'object' && p !== null && typeof (p as any).error === 'string'; } Try / catch
try { await healthApi.requestDevServerRestart(); } catch (e) { if (/restart/i.test(e.message)) showToast('Restart unavailable: ' + e.message); else throw e; } Prevention
- Gate the restart button on dev-mode detection
- Confirm the dev server process is alive before requesting restart
- Disable the control in production builds
- Surface server `error` strings verbatim for diagnosability
When it happens
Trigger: POST dev-server restart endpoint returns 4xx/5xx, e.g. restart not permitted, dev server not running, or route unavailable in production builds.
Common situations: Clicking 'restart dev server' in the UI while the server is compiled/production mode (route disabled), dev process crashed and cannot accept the POST, permission denied by middleware.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Discord failed (HTTP ` : ""} ` : ""})
- | null)?.error ?? `Request failed: `}
- OpenCode API request failed
- OpenCode API returned HTTP
- | null)?.error ?? `Failed to load profile ( )`}
AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-09-10).
Data as JSON: /api/errors/36eb1f7628655e36.
Report an issue: GitHub.
Appendix: source
Thrown at ui/src/api/health.ts:72
if (!res.ok) {
const payload = await res.json().catch(() => null) as { error?: string } | null;
const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);
if (recovery) return recovery;
throw new Error(payload?.error ?? `Failed to load health (${res.status})`);
}
return res.json();
},
requestDevServerRestart: async (): Promise<void> => {
const res = await fetch("/api/health/dev-server/restart", {
method: "POST",
credentials: "include",
headers: { Accept: "application/json" },
});
if (!res.ok) {
const payload = await res.json().catch(() => null) as { error?: string } | null;
const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);
if (recovery) return recovery;
throw new Error(payload?.error ?? `Failed to request restart (${res.status})`);
}
},
};
View on GitHub (pinned to 3f1d897a7c)