{"record":{"id":"96da992736a3b863","repo":"HangfireIO/Hangfire","slug":"sliding-timeout-should-be-greater-than-zero","errorCode":null,"errorMessage":"Sliding timeout should be greater than zero","messagePattern":"Sliding timeout should be greater than zero","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer/SqlServerStorageOptions.cs","lineNumber":118,"sourceCode":"                {\n                    throw new ArgumentException(message, nameof(value));\n                }\n\n                _queuePollInterval = value;\n            }\n        }\n\n        [Obsolete(\"Does not make sense anymore. Background jobs re-queued instantly even after ungraceful shutdown now. Will be removed in 2.0.0.\")]\n        public TimeSpan InvisibilityTimeout { get; set; }\n\n        public TimeSpan? SlidingInvisibilityTimeout\n        {\n            get { return _slidingInvisibilityTimeout; }\n            set\n            {\n                if (value <= TimeSpan.Zero)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), \"Sliding timeout should be greater than zero\");\n                }\n\n                _slidingInvisibilityTimeout = value;\n            }\n        }\n\n        public bool PrepareSchemaIfNecessary { get; set; }\n\n        public TimeSpan JobExpirationCheckInterval \n        {\n            get { return _jobExpirationCheckInterval; } \n            set {\n                if (value.TotalMilliseconds > int.MaxValue)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), \"Job expiration check interval cannot be greater than int.MaxValue\");\n                }\n                _jobExpirationCheckInterval = value;\n            }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer/SqlServerStorageOptions.cs#L100-L136","documentation":"SqlServerStorageOptions.SlidingInvisibilityTimeout was set to zero or a negative TimeSpan, which is invalid. The setter requires a strictly positive value and throws ArgumentOutOfRangeException. This optional property controls a sliding visibility window for queued jobs when non-null.","triggerScenarios":"Setting SlidingInvisibilityTimeout to TimeSpan.Zero or a negative TimeSpan; passing a computed value that collapses to zero.","commonSituations":"Disabling sliding timeout by setting it to zero (the correct way is to leave it null); config-driven durations that produce zero; misunderstanding that null means 'disabled'.","solutions":["Set SlidingInvisibilityTimeout to null to disable sliding visibility (the default), rather than zero.","If enabling it, use a positive value like TimeSpan.FromMinutes(5).","Validate configuration-sourced values before assignment."],"exampleFix":"// before\noptions.SlidingInvisibilityTimeout = TimeSpan.Zero; // throws\n// after — disable by leaving null, or set a positive value\noptions.SlidingInvisibilityTimeout = null; // disabled\n// or:\noptions.SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5);","handlingStrategy":"validation","validationCode":"TimeSpan? sliding = /* from config or null */;\nif (sliding.HasValue && sliding.Value <= TimeSpan.Zero)\n    throw new ArgumentOutOfRangeException(nameof(sliding), \"SlidingInvisibilityTimeout must be positive or null.\");\n\noptions.SlidingInvisibilityTimeout = sliding;","typeGuard":"static bool IsValidSlidingTimeout(TimeSpan? value) => !value.HasValue || value.Value > TimeSpan.Zero;","tryCatchPattern":null,"preventionTips":["Use null to disable sliding visibility timeout, not zero.","Validate config-sourced values before assignment.","Use positive TimeSpan values like TimeSpan.FromMinutes(5) when enabling."],"tags":["options","validation","timespan","configuration"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}