{"record":{"id":"1b9b241cc28ebce6","repo":"paperclipai/paperclip","slug":"managed-restart-did-not-produce-healthy-runtime-se","errorCode":null,"errorMessage":"Managed restart did not produce healthy runtime services.","messagePattern":"Managed restart did not produce healthy runtime services\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/routes/execution-workspaces.ts","lineNumber":848,"sourceCode":"                    ?? null,\n                },\n                adapterEnv: {},\n                onLog,\n                recorder,\n              });\n            }\n            runtimeServiceCount = startedServices.length;\n            await reportRepairPhase(\"managed_restart\", \"succeeded\");\n\n            await reportRepairPhase(\"readiness_validation\", \"started\");\n            if (\n              repairRestartsRuntimeServices\n              && (\n                startedServices.length === 0\n                || startedServices.some((service) => service.status !== \"running\" || service.healthStatus !== \"healthy\")\n              )\n            ) {\n              throw new Error(\"Managed restart did not produce healthy runtime services.\");\n            }\n            await reportRepairPhase(\"readiness_validation\", \"succeeded\");\n          } catch (error) {\n            await reportRepairPhase(repairPhase, \"failed\");\n            throw error;\n          }\n        } else if (action === \"stop\" || action === \"restart\") {\n          await stopRuntimeServicesForExecutionWorkspace({\n            db,\n            executionWorkspaceId: existing.id,\n            workspaceCwd,\n            runtimeServiceId: selectedRuntimeServiceId,\n          });\n        }\n\n        if (action === \"start\" || action === \"restart\") {\n          const availableWorkspace = await ensureWorkspaceAvailable();\n          if (!availableWorkspace) {","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/server/src/routes/execution-workspaces.ts#L830-L866","documentation":"Thrown in the readiness_validation phase of repair after a managed restart of runtime services. When repair was asked to restart services, every started service must end up status \"running\" AND healthStatus \"healthy\"; an empty start list or any service that is not running/healthy fails the phase (server/src/routes/execution-workspaces.ts:848). The repair operation is marked failed at this phase even though the database reseed itself succeeded.","triggerScenarios":"POST repair on a workspace with configured runtime services where startRuntimeServicesForWorkspaceControl returns zero services or at least one service whose status !== \"running\" or healthStatus !== \"healthy\" — app crashes on boot against the freshly seeded DB, health endpoint never turns healthy, port conflict from a service that survived the managed stop.","commonSituations":"The reseeded database has schema/data the service build does not expect (version skew between worktree code and seed); service startup slower than the health window; a stale process still holding the service port after managed_stop; missing env vars or secrets the service needs inside the worktree; migrations not applied by the service on boot.","solutions":["Inspect the workspace operation and the services' own logs (startRuntimeServicesForWorkspaceControl captures output) for the crash or unhealthy reason.","Check for orphaned listeners on the service ports and terminate them, then run the restart action.","Fix the root cause in the worktree (apply migrations, restore required env/secret files) — the DB repair already succeeded, so a plain start/restart is enough afterwards.","If health checks are just slow, retry restart once the service finishes warming up."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const services = listConfiguredRuntimeServiceEntries({ workspaceRuntime: effectiveRuntimeConfig });\nif (services.length === 0) { /* repair skips restart + readiness check entirely */ }\nfor (const s of await api.getRuntimeServices(id)) { if (s.status !== \"running\" || s.healthStatus !== \"healthy\") throw new Error(`Service ${s.id} not healthy; check its logs before repair.`); }","typeGuard":null,"tryCatchPattern":"try { await repair(id); } catch (err) { if (/healthy runtime services/.test(String(err?.body?.error ?? \"\"))) { await inspectServiceLogs(id); await restartServices(id); /* DB repair already succeeded */ } else throw err; }","preventionTips":["Make sure worktree services can boot against a freshly seeded database (migrations, env vars, secrets).","Free the service ports of orphaned processes before repair.","Give services a realistic health-check window so slow starts do not fail readiness."],"tags":["workspace","repair","health-check","runtime-services","paperclip"],"backgroundTag":"health-check-failed","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-21T17:58:32.592Z","contentChangedAt":"2026-08-21T17:58:32.592Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}