different-ai/openwork · error

OpenWork server unavailable.

Error message

OpenWork server unavailable.

What it means

When the server handles provider sync (serverHandlesProviderSync), the store delegates to openworkClient.runCloudProviderSyncNow. If the OpenWork server client is missing from the snapshot it throws 'OpenWork server unavailable.' immediately; a follow-up pushDenSession retry happens only for no_session results, not for a missing client.

Source

Thrown at apps/app/src/react-app/domains/connections/provider-auth/store.ts:2102

      return;
    }
    if (getOpenworkGatewayOrigin()) {
      if (!loggedGatewayCloudProviderSyncSkip) {
        loggedGatewayCloudProviderSyncSkip = true;
        console.info(
          `[cloud-provider-sync:${reason}] Provider materialization is handled server-side in gateway mode.`,
        );
      }
      return { outcome: "handled_server_side" };
    }

    if (serverHandlesProviderSync()) {
      try {
        const result = await enqueueGlobalCloudProviderSync(
          `server:${getCloudProviderSyncContextKey()}`,
          async () => {
            const openworkClient = options.openworkServer.getSnapshot().openworkServerClient;
            if (!openworkClient) throw new Error("OpenWork server unavailable.");
            let result = await openworkClient.runCloudProviderSyncNow(reason);
            if (result.status === "no_session") {
              await pushDenSession(true);
              result = await openworkClient.runCloudProviderSyncNow(reason);
            }
            return result;
          },
        );
        if (!result) throw new Error("Cloud provider sync returned no result.");
        // Re-derive the imported records (and reloadPending/skips) from the
        // server's status after EVERY server-handled pass. Without this the
        // Cloud Providers rows kept whatever the one-shot start() read found
        // (usually nothing) and sat on "Syncing" forever even though the
        // server had long since applied the sync (#3671, UI layer).
        await refreshImportedCloudProviders();
        if (result.status === "failed" || result.status === "no_session") {
          const message = logCloudProviderSyncError(
            reason,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Ensure the OpenWork server is running and the client is connected before triggering sync.
  2. Wait/subscribe for openworkServerClient to appear, then retry the sync.
  3. Catch the error and schedule a retry once connectivity is restored.
  4. If server-side sync is not intended, adjust serverHandlesProviderSync conditions to fall back to local sync.

Example fix

// before
await store.runCloudProviderSync("settings_cloud_opened"); // may throw
// after
try {
  await store.runCloudProviderSync("settings_cloud_opened");
} catch (e) {
  if (String(e.message).includes("OpenWork server unavailable")) {
    await waitForServerConnection();
    await store.runCloudProviderSync("settings_cloud_opened");
  }
}
Defensive patterns

Strategy: retry

Validate before calling

if (!openworkServer.getSnapshot().openworkServerClient) {
  await waitForServerConnection({ timeoutMs: 15000 });
}

Type guard

function serverClientAvailable(s: { openworkServerClient: unknown }): s is { openworkServerClient: NonNullable<unknown> } {
  return s.openworkServerClient != null;
}

Try / catch

try {
  await store.runCloudProviderSync(reason);
} catch (e) {
  if (String((e as Error).message).includes("OpenWork server unavailable")) {
    await waitForServerConnection();
    await store.runCloudProviderSync(reason);
  }
}

Prevention

When it happens

Trigger: runCloudProviderSync invoked with server-side sync enabled while options.openworkServer.getSnapshot().openworkServerClient is null — server not started, still booting, or disconnected.

Common situations: Sync triggered (sign-in, settings page opened, periodic) before the local server connection is ready; server process crashed; headless/test environments lacking server wiring.

Related errors


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