{"record":{"id":"5c03924baeb141de","repo":"github/copilot-sdk","slug":"factory-limit-timeoutseconds-must-not-exceed-m","errorCode":null,"errorMessage":"Factory limit \"timeoutSeconds\" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds","messagePattern":"Factory limit \"timeoutSeconds\" must not exceed (.+?) seconds","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/factory.ts","lineNumber":444,"sourceCode":"        const value = limits[field];\n        if (value !== undefined && (!Number.isInteger(value) || value <= 0)) {\n            throw new Error(`Factory limit \"${field}\" must be a positive integer`);\n        }\n    }\n\n    if (\n        limits.timeoutSeconds !== undefined &&\n        (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)\n    ) {\n        throw new Error(\n            'Factory limit \"timeoutSeconds\" must be a positive, finite number of seconds'\n        );\n    }\n    if (\n        limits.timeoutSeconds !== undefined &&\n        limits.timeoutSeconds > MAX_FACTORY_TIMEOUT_SECONDS\n    ) {\n        throw new Error(\n            `Factory limit \"timeoutSeconds\" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds`\n        );\n    }\n\n    if (limits.maxAiCredits !== undefined) {\n        const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);\n        if (\n            !Number.isFinite(limits.maxAiCredits) ||\n            limits.maxAiCredits <= 0 ||\n            !Number.isSafeInteger(maxNanoAiu) ||\n            maxNanoAiu < 1\n        ) {\n            throw new Error(\n                'Factory limit \"maxAiCredits\" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'\n            );\n        }\n    }\n}","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/factory.ts#L426-L462","documentation":"validateLimits rejects timeoutSeconds values larger than MAX_FACTORY_TIMEOUT_SECONDS (2147483.647 seconds, i.e. 2^31-1 milliseconds) because timeouts are passed as 32-bit millisecond integers to the underlying runtime. Values beyond the cap would overflow the 32-bit signed integer range, so the library throws at definition time.","triggerScenarios":"Calling defineFactory with limits.timeoutSeconds greater than 2147483.647, e.g. passing milliseconds instead of seconds (timeoutSeconds: 300000 intending 5 minutes), or an absurdly large configured timeout.","commonSituations":"Unit confusion: developers who work with millisecond-based timeouts elsewhere (setTimeout) pass milliseconds into a seconds-based field; config values meant for other systems copied verbatim.","solutions":["Convert the value to seconds: divide millisecond values by 1000 before passing.","Use a value at or below 2147483.647 seconds.","Clamp or validate the configured timeout before calling defineFactory.","If a longer timeout is genuinely required, restructure the work instead of relying on a single factory timeout."],"exampleFix":"// before\ndefineFactory({ name: 'build', limits: { timeoutSeconds: 600000 } }); // ms, not s\n// after\ndefineFactory({ name: 'build', limits: { timeoutSeconds: 600 } });","handlingStrategy":"validation","validationCode":"const MAX_FACTORY_TIMEOUT_SECONDS = 2147483.647;\nif (t > MAX_FACTORY_TIMEOUT_SECONDS) throw new RangeError(`timeoutSeconds must be <= ${MAX_FACTORY_TIMEOUT_SECONDS}`);","typeGuard":"function withinMaxTimeout(t) { return t <= 2147483.647; }","tryCatchPattern":"try {\n  defineFactory(meta);\n} catch (e) {\n  if (/must not exceed .* seconds/.test(e.message)) console.error('timeoutSeconds above 32-bit ms cap');\n  throw e;\n}","preventionTips":["Remember the field is seconds, not milliseconds — divide ms values by 1000","Share a single MAX_TIMEOUT constant across the codebase","Clamp configured timeouts to the cap before defining factories"],"tags":["validation","factory","configuration","timeout"],"backgroundTag":"value-out-of-range","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}