{"record":{"id":"89fba5b4892534f9","repo":"thedotmack/claude-mem","slug":"projection-maxpages-must-be-a-positive-safe-integer","errorCode":null,"errorMessage":"projection maxPages must be a positive safe integer","messagePattern":"projection maxPages must be a positive safe integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"workers/sync-hub/src/index.ts","lineNumber":620,"sourceCode":"function projectionNow(dependencies: ProjectionDrainDependencies): number | undefined {\n\treturn dependencies.now?.();\n}\n\n/**\n * Drain one user's authoritative Hub checkpoint through targetSeq. The DO\n * only leases/pages/CAS-advances; all outbound I/O remains in this Worker.\n */\nexport async function drainProjection(\n\tenv: Env,\n\tuserId: string,\n\ttargetSeq: string,\n\tdependencies: ProjectionDrainDependencies = {},\n): Promise<DrainResult> {\n\tif (\n\t\tdependencies.maxPages !== undefined\n\t\t&& (!Number.isSafeInteger(dependencies.maxPages) || dependencies.maxPages < 1)\n\t) {\n\t\tthrow new Error(\"projection maxPages must be a positive safe integer\");\n\t}\n\tconst stub = env.SYNC_HUB.getByName(userId);\n\tlet state = await stub.getProjectionState();\n\tif (decimalAtLeast(state.projected_seq, targetSeq)) {\n\t\treturn { ok: true, projectedSeq: state.projected_seq };\n\t}\n\tif (!env.INTERNAL_PROJECTOR_URL || !env.CMEM_INTERNAL_PROJECTOR_SECRET) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: \"projection_not_configured\",\n\t\t\tprojectedSeq: state.projected_seq,\n\t\t\thttpStatus: 503,\n\t\t\tretryable: true,\n\t\t};\n\t}\n\tconst acquiredAt = projectionNow(dependencies);\n\tconst lease = acquiredAt === undefined\n\t\t? await stub.acquireProjectionLease(targetSeq)","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/workers/sync-hub/src/index.ts#L602-L638","documentation":"drainProjection validates dependencies.maxPages before draining. maxPages bounds how many pages of authoritative ops one drain may fetch, so a lagging user cannot monopolize a cron request or hold the per-user projection lease indefinitely. The error fires when a caller supplies an explicitly provided maxPages that is not a positive safe integer (0, negative, fractional, NaN, or Infinity) — an invalid dependency-injection input at the drain boundary, not a projection/runtime failure.","triggerScenarios":"Thrown at workers/sync-hub/src/index.ts:620 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass maxPages as a positive safe integer, or omit it entirely to use the caller's default page budget","Clamp/round caller-supplied page counts before constructing ProjectionDrainDependencies","Align test and scheduled-repair callers with the REPAIR_DRAIN_MAX_PAGES-style positive-integer convention"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}