{"record":{"id":"28dcff75c4798323","repo":"louislam/uptime-kuma","slug":"screenshot-delay-must-be-a-non-negative-number","errorCode":null,"errorMessage":"Screenshot delay must be a non-negative number","messagePattern":"Screenshot delay must be a non-negative number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":1755,"sourceCode":"                    pingGlobalTimeout < this.ping_per_request_timeout ||\n                    pingGlobalTimeout < PING_GLOBAL_TIMEOUT_MIN ||\n                    pingGlobalTimeout > PING_GLOBAL_TIMEOUT_MAX\n                ) {\n                    throw new Error(\n                        `Timeout must be between ${PING_GLOBAL_TIMEOUT_MIN} and ${PING_GLOBAL_TIMEOUT_MAX} seconds (default: ${PING_GLOBAL_TIMEOUT_DEFAULT})`\n                    );\n                }\n\n                this.timeout = pingGlobalTimeout;\n            }\n        }\n\n        if (this.type === \"real-browser\") {\n            // screenshot_delay validation\n            if (this.screenshot_delay !== undefined && this.screenshot_delay !== null) {\n                const delay = Number(this.screenshot_delay);\n                if (isNaN(delay) || delay < 0) {\n                    throw new Error(\"Screenshot delay must be a non-negative number\");\n                }\n\n                // Must not exceed 0.8 * timeout (page.goto timeout is interval * 1000 * 0.8)\n                const maxDelayFromTimeout = this.interval * 1000 * 0.8;\n                if (delay >= maxDelayFromTimeout) {\n                    throw new Error(`Screenshot delay must be less than ${maxDelayFromTimeout}ms (0.8 × interval)`);\n                }\n\n                // Must not exceed 0.5 * interval to prevent blocking next check\n                const maxDelayFromInterval = this.interval * 1000 * 0.5;\n                if (delay >= maxDelayFromInterval) {\n                    throw new Error(`Screenshot delay must be less than ${maxDelayFromInterval}ms (0.5 × interval)`);\n                }\n            }\n        }\n\n        if (this.type === \"mongodb\" && this.databaseQuery) {\n            // Validate that databaseQuery is valid JSON","sourceCodeStart":1737,"sourceCodeEnd":1773,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L1737-L1773","documentation":"Thrown by Monitor.validate() for type \"real-browser\" when screenshot_delay is set (not undefined/null) and Number(screenshot_delay) is NaN or negative. The delay is the milliseconds the headless browser waits after navigation before capturing the screenshot.","triggerScenarios":"Save a real-browser monitor with screenshot_delay=\"abc\" (NaN), =-100, or an empty string (coerces to 0, which is allowed). The guard runs only when the field is present.","commonSituations":"User enters the delay as a fraction with a comma locale (\"0,5\" -> NaN). Negative values from a misconfigured form default. Passing the field as a string with units (\"500ms\").","solutions":["Set screenshot_delay to a non-negative number of milliseconds, or omit it.","Strip any non-numeric characters and use a dot decimal separator before submission.","If you need zero delay, use 0 explicitly or leave the field blank."],"exampleFix":"// before\n{ type: \"real-browser\", screenshot_delay: \"500ms\" }\n// after\n{ type: \"real-browser\", screenshot_delay: 500 }","handlingStrategy":"validation","validationCode":"function validScreenshotDelay(v) {\n  if (v == null) return true;\n  const n = Number(v);\n  return !isNaN(n) && n >= 0;\n}","typeGuard":"function isScreenshotDelay(v) {\n  if (v == null) return true;\n  const n = Number(v);\n  return typeof n === \"number\" && !isNaN(n) && n >= 0;\n}","tryCatchPattern":"try {\n  await bean.validate();\n} catch (e) {\n  if (/Screenshot delay must be a non-negative/.test(e.message)) return badRequest(\"screenshot_delay must be >= 0 ms\");\n  throw e;\n}","preventionTips":["Accept only numeric input in the form.","Strip units and locale commas before submission."],"tags":["monitor","real-browser","validation","uptime-kuma"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}