different-ai/openwork · critical

OpenWork server did not stay running after startup.

Error message

OpenWork server did not stay running after startup.

What it means

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.

Source

Thrown at apps/desktop/electron/main.mjs:1375

  } catch {
    // Ignore renderer teardown races during quit.
  }
}

async function disposeRuntimeBeforeQuit() {
  if (runtimeDisposedForQuit || runtimeDisposeInProgress) return;
  runtimeDisposeInProgress = true;
  try {
    await runtimeManager.dispose().catch(() => undefined);
    runtimeDisposedForQuit = true;
  } finally {
    runtimeDisposeInProgress = false;
  }
}

function assertOpenworkServerReady(info) {
  if (!info?.running) {
    throw new Error("OpenWork server did not stay running after startup.");
  }
  if (!info.baseUrl) {
    throw new Error("OpenWork server did not report a base URL after startup.");
  }
  if (!info.ownerToken && !info.clientToken) {
    throw new Error("OpenWork server did not report an access token after startup.");
  }
  return info;
}

async function bootRuntimeForSelectedWorkspace() {
  if (typeof process.env.OPENWORK_EVAL_FATAL_DESKTOP_BOOTSTRAP_FAILURE === "string") {
    throw new Error(process.env.OPENWORK_EVAL_FATAL_DESKTOP_BOOTSTRAP_FAILURE);
  }
  const list = await workspaceStore.readWorkspaceState();
  const selectedId = list.selectedId || list.activeId || list.workspaces[0]?.id || "";
  const workspace = selectedId
    ? list.workspaces.find((entry) => entry?.id === selectedId)

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check the openwork-server logs/stderr for the crash cause (port in use, bad config, missing binary).
  2. Kill a stale openwork-server process holding the port, then restart the app.
  3. Reset/repair the app's userData server config (rename the folder to force regeneration).
  4. Retry startup with backoff and surface server stderr to the user instead of only asserting.

Example fix

// before
assertOpenworkServerReady(info); // throws if info.running false
// after
if (!info?.running) {
  console.error('Server not running. stderr:', info?.lastError ?? 'unknown');
}
assertOpenworkServerReady(info);
Defensive patterns

Strategy: try-catch

Validate before calling

const info = await runtimeManager.getStatus();
if (!info || info.running !== true) {
  console.error('Server not running before asserting readiness.');
}

Type guard

function isServerRunning(info) {
  return Boolean(info && info.running === true);
}

Try / catch

try {
  assertOpenworkServerReady(info);
} catch (err) {
  if (String(err.message).includes('did not stay running')) {
    console.error('Server crashed at startup — check server logs/port conflicts.');
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/098a505f504db87a. Report an issue: GitHub.