{"record":{"id":"098a505f504db87a","repo":"different-ai/openwork","slug":"openwork-server-did-not-stay-running-after-startup","errorCode":null,"errorMessage":"OpenWork server did not stay running after startup.","messagePattern":"OpenWork server did not stay running after startup\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"apps/desktop/electron/main.mjs","lineNumber":1375,"sourceCode":"  } catch {\n    // Ignore renderer teardown races during quit.\n  }\n}\n\nasync function disposeRuntimeBeforeQuit() {\n  if (runtimeDisposedForQuit || runtimeDisposeInProgress) return;\n  runtimeDisposeInProgress = true;\n  try {\n    await runtimeManager.dispose().catch(() => undefined);\n    runtimeDisposedForQuit = true;\n  } finally {\n    runtimeDisposeInProgress = false;\n  }\n}\n\nfunction assertOpenworkServerReady(info) {\n  if (!info?.running) {\n    throw new Error(\"OpenWork server did not stay running after startup.\");\n  }\n  if (!info.baseUrl) {\n    throw new Error(\"OpenWork server did not report a base URL after startup.\");\n  }\n  if (!info.ownerToken && !info.clientToken) {\n    throw new Error(\"OpenWork server did not report an access token after startup.\");\n  }\n  return info;\n}\n\nasync function bootRuntimeForSelectedWorkspace() {\n  if (typeof process.env.OPENWORK_EVAL_FATAL_DESKTOP_BOOTSTRAP_FAILURE === \"string\") {\n    throw new Error(process.env.OPENWORK_EVAL_FATAL_DESKTOP_BOOTSTRAP_FAILURE);\n  }\n  const list = await workspaceStore.readWorkspaceState();\n  const selectedId = list.selectedId || list.activeId || list.workspaces[0]?.id || \"\";\n  const workspace = selectedId\n    ? list.workspaces.find((entry) => entry?.id === selectedId)","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/main.mjs#L1357-L1393","documentation":"assertOpenworkServerReady() validates the runtime manager's server status after startup. If info.running is falsy — the bundled OpenWork server process exited or never reached a running state — this error is thrown, distinguishing it from the follow-up checks for baseUrl and tokens.","triggerScenarios":"Calling assertOpenworkServerReady(info) with info null/undefined or info.running === false, e.g. the spawned server crashed at boot, the port bind failed, or the runtime reported a non-running state after startup attempts.","commonSituations":"Port conflict with another openwork-server instance; server binary missing or crashing due to bad userData config; startup timeout treated as not-running; corrupted state in userData preventing boot.","solutions":["Check the openwork-server logs/stderr for the crash cause (port in use, bad config, missing binary).","Kill a stale openwork-server process holding the port, then restart the app.","Reset/repair the app's userData server config (rename the folder to force regeneration).","Retry startup with backoff and surface server stderr to the user instead of only asserting."],"exampleFix":"// before\nassertOpenworkServerReady(info); // throws if info.running false\n// after\nif (!info?.running) {\n  console.error('Server not running. stderr:', info?.lastError ?? 'unknown');\n}\nassertOpenworkServerReady(info);","handlingStrategy":"try-catch","validationCode":"const info = await runtimeManager.getStatus();\nif (!info || info.running !== true) {\n  console.error('Server not running before asserting readiness.');\n}","typeGuard":"function isServerRunning(info) {\n  return Boolean(info && info.running === true);\n}","tryCatchPattern":"try {\n  assertOpenworkServerReady(info);\n} catch (err) {\n  if (String(err.message).includes('did not stay running')) {\n    console.error('Server crashed at startup — check server logs/port conflicts.');\n  } else throw err;\n}","preventionTips":["Check for port conflicts with a stale openwork-server process.","Capture and surface server stderr at startup.","Validate userData server config before launch.","Add a startup retry with backoff before asserting readiness."],"tags":["server","startup","electron"],"backgroundTag":"server-failed-to-start","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}