different-ai/openwork · critical

Cannot find OpenWork embedded server bundle. Checked: ${cand

Error message

Cannot find OpenWork embedded server bundle. Checked: ${candidates.join(", ")}

What it means

When starting the embedded OpenWork server, the runtime probes a list of candidate bundle paths (packaged paths plus a dev path, ordered by OPENWORK_DEV_MODE). If none of them exists on disk it throws this error listing every path it checked. It means the server bundle was never built or is installed somewhere the app doesn't expect.

Source

Thrown at apps/desktop/electron/runtime.mjs:1938

    );
    const activeWorkspace = selectStickyOpenworkPortWorkspace(requestedWorkspacePaths, workspacePaths);
    const portSelection = await resolveOpenworkPort(host, activeWorkspace, currentPort);
    const tokens = await loadServerCredentials();

    // One call: resolve config, spawn managed OpenCode, start HTTP server.
    // Dev must prefer apps/server/dist; build output also stages a packaged
    // copy under apps/desktop/server for electron-builder.
    const devPath = path.resolve(__runtimeDir, "..", "..", "server", "dist", "embedded.js");
    const packagedPaths = [
      path.resolve(__runtimeDir, "..", "server", "dist", "embedded.js"),
      ...(process.resourcesPath ? [path.resolve(process.resourcesPath, "server", "dist", "embedded.js")] : []),
    ];
    const candidates = process.env.OPENWORK_DEV_MODE === "1"
      ? [devPath, ...packagedPaths]
      : [...packagedPaths, devPath];
    const embeddedPath = candidates.find((candidate) => existsSync(candidate));
    if (!embeddedPath) {
      throw new Error(`Cannot find OpenWork embedded server bundle. Checked: ${candidates.join(", ")}`);
    }
    const { startEmbeddedServer } = await import(embeddedServerImportUrl(embeddedPath));
    // startEmbeddedServer falls back to an OS-assigned port if `port` races
    // into EADDRINUSE (see apps/server/src/serve-node.ts), so the bound port
    // below is authoritative.
    const handle = await startEmbeddedServer({
      host,
      port: portSelection.port,
      corsOrigins: ["*"],
      approvalMode: "auto",
      configPath: serverConfigPath,
      workspaces: workspacePaths,
      token: tokens.clientToken,
      hostToken: tokens.hostToken,
      opencodeBaseUrl: options.opencodeBaseUrl ?? undefined,
      opencodeDirectory: activeWorkspace || undefined,
      manageOpencode: options.manageOpencode === true,
      opencodeBin: managedOpencode?.path ?? undefined,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Build the server bundle (`pnpm build` in apps/server or the repo's build-all script) so the dev path exists.
  2. If running a packaged install, rebuild/repackage the desktop app so the server bundle is included in resources.
  3. Set OPENWORK_DEV_MODE=1 only when the dev bundle exists; unset it to fall back to packaged paths (or vice versa).
  4. Read the `Checked:` list in the error and confirm the expected path exists, then fix the packaging config or copy the bundle there.

Example fix

// before
export OPENWORK_DEV_MODE=1   # dev bundle never built
// after
pnpm --filter @openwork/server build && export OPENWORK_DEV_MODE=1
Defensive patterns

Strategy: fallback

Validate before calling

const candidatePaths = process.env.OPENWORK_DEV_MODE === "1" ? [devPath, ...packagedPaths] : [...packagedPaths, devPath];
if (!candidatePaths.some((p) => existsSync(p))) {
  throw new Error(`Server bundle missing; build it or check packaging. Expected one of: ${candidatePaths.join(", ")}`);
}

Try / catch

let handle;
try {
  handle = await startOpenworkEmbeddedServer();
} catch (err) {
  if (String(err.message).startsWith("Cannot find OpenWork embedded server bundle")) {
    dialog.showErrorBox("Server bundle missing", "Rebuild the app: pnpm build && pnpm package");
    app.quit();
  } else { throw err; }
}

Prevention

When it happens

Trigger: Starting the app (embedded server boot) when `existsSync` fails for every candidate: packaged bundle absent from install resources, or dev bundle absent and OPENWORK_DEV_MODE toggled incorrectly.

Common situations: Running from source without building the server (`@openwork/server` dist missing); a packaging/CI step that skipped bundling the server; setting OPENWORK_DEV_MODE=1 in an environment where the dev bundle was never built; installing an app build that shipped without the embedded server.

Related errors


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