{"record":{"id":"d2c735254ef751da","repo":"different-ai/openwork","slug":"openwork-server-unavailable","errorCode":null,"errorMessage":"OpenWork server unavailable.","messagePattern":"OpenWork server unavailable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/connections/provider-auth/store.ts","lineNumber":2102,"sourceCode":"      return;\n    }\n    if (getOpenworkGatewayOrigin()) {\n      if (!loggedGatewayCloudProviderSyncSkip) {\n        loggedGatewayCloudProviderSyncSkip = true;\n        console.info(\n          `[cloud-provider-sync:${reason}] Provider materialization is handled server-side in gateway mode.`,\n        );\n      }\n      return { outcome: \"handled_server_side\" };\n    }\n\n    if (serverHandlesProviderSync()) {\n      try {\n        const result = await enqueueGlobalCloudProviderSync(\n          `server:${getCloudProviderSyncContextKey()}`,\n          async () => {\n            const openworkClient = options.openworkServer.getSnapshot().openworkServerClient;\n            if (!openworkClient) throw new Error(\"OpenWork server unavailable.\");\n            let result = await openworkClient.runCloudProviderSyncNow(reason);\n            if (result.status === \"no_session\") {\n              await pushDenSession(true);\n              result = await openworkClient.runCloudProviderSyncNow(reason);\n            }\n            return result;\n          },\n        );\n        if (!result) throw new Error(\"Cloud provider sync returned no result.\");\n        // Re-derive the imported records (and reloadPending/skips) from the\n        // server's status after EVERY server-handled pass. Without this the\n        // Cloud Providers rows kept whatever the one-shot start() read found\n        // (usually nothing) and sat on \"Syncing\" forever even though the\n        // server had long since applied the sync (#3671, UI layer).\n        await refreshImportedCloudProviders();\n        if (result.status === \"failed\" || result.status === \"no_session\") {\n          const message = logCloudProviderSyncError(\n            reason,","sourceCodeStart":2084,"sourceCodeEnd":2120,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/connections/provider-auth/store.ts#L2084-L2120","documentation":"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.","triggerScenarios":"runCloudProviderSync invoked with server-side sync enabled while options.openworkServer.getSnapshot().openworkServerClient is null — server not started, still booting, or disconnected.","commonSituations":"Sync triggered (sign-in, settings page opened, periodic) before the local server connection is ready; server process crashed; headless/test environments lacking server wiring.","solutions":["Ensure the OpenWork server is running and the client is connected before triggering sync.","Wait/subscribe for openworkServerClient to appear, then retry the sync.","Catch the error and schedule a retry once connectivity is restored.","If server-side sync is not intended, adjust serverHandlesProviderSync conditions to fall back to local sync."],"exampleFix":"// before\nawait store.runCloudProviderSync(\"settings_cloud_opened\"); // may throw\n// after\ntry {\n  await store.runCloudProviderSync(\"settings_cloud_opened\");\n} catch (e) {\n  if (String(e.message).includes(\"OpenWork server unavailable\")) {\n    await waitForServerConnection();\n    await store.runCloudProviderSync(\"settings_cloud_opened\");\n  }\n}","handlingStrategy":"retry","validationCode":"if (!openworkServer.getSnapshot().openworkServerClient) {\n  await waitForServerConnection({ timeoutMs: 15000 });\n}","typeGuard":"function serverClientAvailable(s: { openworkServerClient: unknown }): s is { openworkServerClient: NonNullable<unknown> } {\n  return s.openworkServerClient != null;\n}","tryCatchPattern":"try {\n  await store.runCloudProviderSync(reason);\n} catch (e) {\n  if (String((e as Error).message).includes(\"OpenWork server unavailable\")) {\n    await waitForServerConnection();\n    await store.runCloudProviderSync(reason);\n  }\n}","preventionTips":["Ensure the OpenWork server process is launched before any sync triggers","Queue syncs fired at startup until the client snapshot is ready","Distinguish no_session (retry after pushDenSession) from missing-client failures","Add health checks before periodic sync jobs"],"tags":["server","connection","sync"],"backgroundTag":"client-not-connected","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}