{"record":{"id":"7af288cd5ea86c43","repo":"ElectronNET/Electron.NET","slug":"argument-must-be-greater-then-0","errorCode":null,"errorMessage":"Argument must be greater then 0","messagePattern":"Argument must be greater then 0","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/ElectronNET.API/Common/ProcessRunner.cs","lineNumber":274,"sourceCode":"        /// <summary>Sychronously waits for the specified amount and ends the process afterwards.</summary>\n        /// <param name=\"timeoutMs\">The timeout ms.</param>\n        /// <remarks>This method allows for a clean exit, since it also waits until the StandardOutput and\n        /// StandardError pipes are processed to the end.</remarks>\n        /// <returns>true, if the process has exited gracefully; false otherwise.</returns>\n        public bool WaitAndKill(int timeoutMs)\n        {\n            var proc = this.process;\n\n            if (proc == null)\n            {\n                return true;\n            }\n\n            try\n            {\n                if (timeoutMs <= 0)\n                {\n                    throw new ArgumentException(\"Argument must be greater then 0\", nameof(timeoutMs));\n                }\n\n                // Timed waiting. We need to wait for I/O ourselves.\n                if (!proc.WaitForExit(timeoutMs))\n                {\n                    this.Cancel();\n                }\n\n                // Wait for the I/O to finish.\n                var waitMs = (int)(timeoutMs - this.stopwatch.ElapsedMilliseconds);\n                waitMs = Math.Max(waitMs, 10);\n                this.stdOutEvent?.WaitOne(waitMs);\n\n                waitMs = (int)(timeoutMs - this.stopwatch.ElapsedMilliseconds);\n                waitMs = Math.Max(waitMs, 10);\n                return this.stdErrEvent?.WaitOne(waitMs) ?? false;\n            }\n            finally","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/ElectronNET/Electron.NET/blob/87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2/src/ElectronNET.API/Common/ProcessRunner.cs#L256-L292","documentation":"ProcessRunner.WaitAndKill waits for the spawned process to exit for up to timeoutMs milliseconds and then kills it. It validates that timeoutMs is strictly positive inside the timed-wait path and throws ArgumentException (note the message's typo 'then' for 'than') when timeoutMs <= 0, since a non-positive timeout cannot express a wait duration.","triggerScenarios":"Calling WaitAndKill with timeoutMs equal to 0, negative, or default(0) — e.g. passing Timeout.Infinite-style or computed values that evaluated to 0, or relying on a default int value.","commonSituations":"Config value for a process timeout read as 0 because the config key was missing/default; arithmetic on timeouts that underflowed; caller intending 'no timeout' passing 0 instead of a large value or the appropriate infinite constant; deserialized settings object with uninitialized int.","solutions":["Pass a positive timeout in milliseconds, e.g. WaitAndKill(process, 5000).","Fix the timeout computation so it cannot evaluate to <= 0 (use Math.Max(1, computed)).","Set the configured timeout value in your settings source to a non-zero value.","If 'wait indefinitely' was intended, use the runner's non-timed wait path/API instead of passing 0."],"exampleFix":"// before\nprocessRunner.WaitAndKill(process, timeoutMs);\n// after\nprocessRunner.WaitAndKill(process, Math.Max(1000, timeoutMs));","handlingStrategy":"validation","validationCode":"if (timeoutMs <= 0)\n    throw new ArgumentOutOfRangeException(nameof(timeoutMs), \"Provide a positive timeout in milliseconds.\");\nprocessRunner.WaitAndKill(process, timeoutMs);","typeGuard":null,"tryCatchPattern":"try\n{\n    processRunner.WaitAndKill(process, timeoutMs);\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(timeoutMs))\n{\n    Logger.Error(\"WaitAndKill requires timeoutMs > 0; check your timeout configuration.\");\n}","preventionTips":["Clamp computed timeouts with Math.Max(minTimeout, value).","Give timeout settings sane non-zero defaults in config classes.","Validate config-loaded timeouts at startup, not at use site.","Avoid relying on default(int) = 0 for 'unset' timeouts; use nullable int and resolve explicitly."],"tags":["process","argument","timeout","validation"],"backgroundTag":"argument-out-of-range","analyzedSha":"87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2","analyzedAt":"2026-09-14T03:09:47.608Z","contentChangedAt":"2026-09-14T03:09:47.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}