{"record":{"id":"9a3db8bcead1e16e","repo":"diegosouzapw/OmniRoute","slug":"sync-failed","errorCode":null,"errorMessage":"Sync failed","messagePattern":"Sync failed","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/services/cloudSyncScheduler.ts","lineNumber":112,"sourceCode":"  async sync() {\n    // Check if cloud is enabled\n    const enabled = await isCloudEnabled();\n    if (!enabled) {\n      return null;\n    }\n\n    await this.initializeMachineId();\n\n    // Call internal API route which handles both sync and token update\n    const response = await fetch(`${INTERNAL_BASE_URL}/api/sync/cloud`, {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application/json\" },\n      body: JSON.stringify({ machineId: this.machineId, action: \"sync\" }),\n    });\n\n    if (!response.ok) {\n      const errorData = await response.json().catch(() => ({}));\n      throw new Error(errorData.error || \"Sync failed\");\n    }\n\n    const result = await response.json();\n    return result;\n  }\n\n  /**\n   * Check if scheduler is running\n   */\n  isRunning() {\n    return this.intervalId !== null;\n  }\n}\n\n// Export a singleton instance if needed\nlet cloudSyncScheduler: CloudSyncScheduler | null = null;\n\nexport async function getCloudSyncScheduler(machineId: string | null = null, intervalMinutes = 15) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/shared/services/cloudSyncScheduler.ts#L94-L130","documentation":"Generic failure error from the cloud sync scheduler: the internal POST to /api/sync/cloud returned a non-ok status. The thrown message is the bare sentinel \"Sync failed\"; the response body's error detail is appended when present. It means the server-to-server sync round (config push/token refresh) was rejected upstream.","triggerScenarios":"Thrown at src/shared/services/cloudSyncScheduler.ts:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the server log/response body for the underlying error detail from /api/sync/cloud","Verify cloud sync is enabled and the cloud endpoint (NEXT_PUBLIC_CLOUD_URL) is reachable","Re-authenticate the cloud token if the failure is 401/403","Retry the scheduler tick after connectivity is restored"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}