{"record":{"id":"e64b1cc96a33b858","repo":"HangfireIO/Hangfire","slug":"schedulepollinginterval-must-be-non-negative-and-e","errorCode":null,"errorMessage":"SchedulePollingInterval must be non-negative and either equal to or less than {Int32.MaxValue} milliseconds","messagePattern":"SchedulePollingInterval must be non-negative and either equal to or less than (.+?) milliseconds","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/BackgroundJobServerOptions.cs","lineNumber":123,"sourceCode":"            get { return _shutdownTimeout; }\n            set\n            {\n                if ((value < TimeSpan.Zero && value != Timeout.InfiniteTimeSpan) || value.TotalMilliseconds > Int32.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"ShutdownTimeout must be either equal to or less than {Int32.MaxValue} milliseconds and non-negative or infinite\");\n                }\n                _shutdownTimeout = value;\n            }\n        }\n\n        public TimeSpan SchedulePollingInterval\n        {\n            get { return _schedulePollingInterval; }\n            set\n            {\n                if (value < TimeSpan.Zero || value.TotalMilliseconds > Int32.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"SchedulePollingInterval must be non-negative and either equal to or less than {Int32.MaxValue} milliseconds\");\n                }\n\n                _schedulePollingInterval = value;\n            }\n        }\n\n        public TimeSpan HeartbeatInterval\n        {\n            get { return _heartbeatInterval; }\n            set\n            {\n                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxHeartbeatInterval)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"HeartbeatInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxHeartbeatInterval.Hours} hours\");\n                }\n                _heartbeatInterval = value;\n            }\n        }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/BackgroundJobServerOptions.cs#L105-L141","documentation":"This ArgumentOutOfRangeException(\"value\", \"SchedulePollingInterval must be non-negative and either equal to or less than Int32.MaxValue milliseconds\") is thrown by the SchedulePollingInterval setter of BackgroundJobServerOptions. Unlike the timeouts, this setter does NOT accept Timeout.InfiniteTimeSpan as a special case (any negative value is rejected) and rejects values over Int32.MaxValue total milliseconds. The interval governs how often the DelayedJobScheduler polls storage for due delayed jobs.","triggerScenarios":"Assigning options.SchedulePollingInterval = TimeSpan.FromSeconds(-1); assigning Timeout.InfiniteTimeSpan (rejected here, unlike timeouts); assigning a TimeSpan whose total milliseconds exceed Int32.MaxValue.","commonSituations":"Attempting to disable delayed-job polling by setting the interval to Timeout.InfiniteTimeSpan (not allowed); config typos; unit confusion; binding a huge or negative value from configuration.","solutions":["Use a non-negative TimeSpan within Int32.MaxValue ms (the default is DelayedJobScheduler.DefaultPollingDelay, 15s).","To effectively disable polling on a lightweight server, set IsLightweightServer = true instead of an infinite interval.","Clamp the bound value into the legal range.","Validate the configured value at startup."],"exampleFix":"// before\noptions.SchedulePollingInterval = Timeout.InfiniteTimeSpan; // rejected\n\n// after\noptions.IsLightweightServer = true; // excludes the delayed-job scheduler entirely","handlingStrategy":"validation","validationCode":"TimeSpan SanitizeInterval(TimeSpan ts) =>\n    ts >= TimeSpan.Zero && ts.TotalMilliseconds <= int.MaxValue ? ts : DelayedJobScheduler.DefaultPollingDelay;\noptions.SchedulePollingInterval = SanitizeInterval(parsed);","typeGuard":"static bool IsValidInterval(TimeSpan ts) => ts >= TimeSpan.Zero && ts.TotalMilliseconds <= int.MaxValue;","tryCatchPattern":"try { options.SchedulePollingInterval = parsed; }\ncatch (ArgumentOutOfRangeException) { options.SchedulePollingInterval = DelayedJobScheduler.DefaultPollingDelay; }","preventionTips":["Note: Timeout.InfiniteTimeSpan is NOT accepted here.","Use IsLightweightServer=true to drop the scheduler.","Clamp bound values."],"tags":["csharp","hangfire","argumentoutofrangeexception","configuration","timeout","validation","background-jobs"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}