{"record":{"id":"36eb1f7628655e36","repo":"paperclipai/paperclip","slug":"payload-error-failed-to-request-restart","errorCode":null,"errorMessage":"${payload?.error ?? `Failed to request restart (${res.status})`}","messagePattern":"\\$\\{payload\\?\\.error \\?\\? `Failed to request restart \\(\\$\\{res\\.status\\}\\)`\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/src/api/health.ts","lineNumber":71,"sourceCode":"    if (!res.ok) {\n      const payload = await res.json().catch(() => null) as { error?: string } | null;\n      const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);\n      if (recovery) return recovery;\n      throw new Error(payload?.error ?? `Failed to load health (${res.status})`);\n    }\n    return res.json();\n  },\n  requestDevServerRestart: async (): Promise<void> => {\n    const res = await fetch(\"/api/health/dev-server/restart\", {\n      method: \"POST\",\n      credentials: \"include\",\n      headers: { Accept: \"application/json\" },\n    });\n    if (!res.ok) {\n      const payload = await res.json().catch(() => null) as { error?: string } | null;\n      const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, payload);\n      if (recovery) return recovery;\n      throw new Error(payload?.error ?? `Failed to request restart (${res.status})`);\n    }\n  },\n};\n","sourceCodeStart":53,"sourceCodeEnd":75,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/ui/src/api/health.ts#L53-L75","documentation":"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.","triggerScenarios":"POST dev-server restart endpoint returns 4xx/5xx, e.g. restart not permitted, dev server not running, or route unavailable in production builds.","commonSituations":"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.","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"],"exampleFix":"// before\nthrow new Error(payload?.error ?? `Failed to request restart (${res.status})`);\n// after\nif (res.status === 404) throw new Error('Dev-server restart is only available in development mode.');\nthrow new Error(payload?.error ?? `Failed to request restart (${res.status})`);","handlingStrategy":"fallback","validationCode":"const isDev = import.meta.env.DEV; if (!isDev) return; // restart route only exists in dev","typeGuard":"function isRestartError(p: unknown): p is { error: string } { return typeof p === 'object' && p !== null && typeof (p as any).error === 'string'; }","tryCatchPattern":"try { await healthApi.requestDevServerRestart(); } catch (e) { if (/restart/i.test(e.message)) showToast('Restart unavailable: ' + e.message); else throw e; }","preventionTips":["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"],"tags":["http","dev-server","api"],"backgroundTag":"http-error-response","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}