{"record":{"id":"9f8eb9c503cf1eef","repo":"hcengineering/platform","slug":"max-retries-maxretries-exceeded-while-loading","errorCode":null,"errorMessage":"Max retries (${maxRetries}) exceeded while loading chunks for domain ${domain}","messagePattern":"Max retries \\((.+?)\\) exceeded while loading chunks for domain (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/backup/src/backup.ts","lineNumber":466,"sourceCode":"              workspace: workspaceId,\n              url: wsIds.url\n            })\n            await ctx.with('closeChunk', {}, async () => {\n              await connection.closeChunk(ctx, idx as number)\n            })\n            break\n          }\n        } catch (err: any) {\n          retryCount++\n          ctx.error('failed to load chunks', { error: err, retryCount, maxRetries })\n          if (idx !== undefined) {\n            await ctx.with('closeChunk', {}, async () => {\n              await connection.closeChunk(ctx, idx as number)\n            })\n          }\n          if (retryCount >= maxRetries) {\n            ctx.error('Max retries exceeded in loadChangesFromServer', { domain, retryCount })\n            throw new Error(`Max retries (${maxRetries}) exceeded while loading chunks for domain ${domain}`)\n          }\n          // Try again with delay\n          await new Promise<void>((resolve) => setTimeout(resolve, 1000 * retryCount))\n          idx = undefined\n          processed = 0\n        }\n      }\n      return { changed, needRetrieveChunks }\n    }\n\n    let domainChanges = 0\n    async function processDomain (\n      ctx: MeasureContext,\n      domain: Domain,\n      progress: (value: number) => Promise<void>\n    ): Promise<void> {\n      const changes: Snapshot = {\n        added: new Map(),","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/backup/src/backup.ts#L448-L484","documentation":"loadChangesFromServer retries fetching backup chunks for a domain up to maxRetries times; when retryCount still exceeds the limit it logs 'Max retries exceeded' and throws this Error. It signals persistent failure to retrieve change chunks from the server during backup/traversal.","triggerScenarios":"Repeated chunk load failures (network errors, server 5xx, timeouts) during loadChangesFromServer such that retryCount >= maxRetries while iterating chunks for a domain; callers include changed/needRetrieveChunks.","commonSituations":"Backup worker running against a flaky or overloaded transactor; long-running backups interrupted by network partitions; server restarted mid-backup; maxRetries configured too low for an unstable network.","solutions":["Verify connectivity to the backup/transactor server and retry the backup operation.","Increase maxRetries (and note the built-in backoff is 1000ms * retryCount) for unstable networks.","Check server logs for the underlying chunk-load failure causing each retry.","Re-run the backup during lower load or from a node closer to the server."],"exampleFix":"// config\n// before\nconst maxRetries = 3\n// after\nconst maxRetries = 10 // tolerate longer transient outages","handlingStrategy":"retry","validationCode":"// pre-check server reachability before the backup\nconst ok = await fetch(`${serverUrl}/health`).then(r => r.ok).catch(() => false)\nif (!ok) throw new Error('Backup server unreachable; aborting before chunk loading')","typeGuard":null,"tryCatchPattern":"try {\n  await loadChangesFromServer(ctx, ...)\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Max retries')) {\n    // exponential backoff, then reschedule the whole backup job\n  } else throw err\n}","preventionTips":["Run backups on stable network paths and monitor server health.","Tune maxRetries relative to network reliability; the built-in backoff is linear (1s * attempt).","Alert on the ctx.error log line before the throw to catch degradation early.","Resume/incremental backup support reduces cost of a failed run."],"tags":["backup","retry","network"],"backgroundTag":"max-retries-exceeded","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}