{"record":{"id":"05e5a79702edb1ff","repo":"jackwener/OpenCLI","slug":"runtime-invalid-envvar-raw-using-defaul","errorCode":null,"errorMessage":"[runtime] Invalid ${envVar}=\"${raw}\", using default ${fallback}s","messagePattern":"\\[runtime\\] Invalid (.+?)=\"(.+?)\", using default (.+?)s","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/browser/config.ts","lineNumber":8,"sourceCode":"import { log } from '../logger.js';\n\nfunction parseEnvTimeout(envVar: string, fallback: number): number {\n  const raw = process.env[envVar];\n  if (raw === undefined) return fallback;\n  const parsed = parseInt(raw, 10);\n  if (Number.isNaN(parsed) || parsed <= 0) {\n    log.warn(`[runtime] Invalid ${envVar}=\"${raw}\", using default ${fallback}s`);\n    return fallback;\n  }\n  return parsed;\n}\n\nexport const DEFAULT_BROWSER_CONNECT_TIMEOUT = parseEnvTimeout('OPENCLI_BROWSER_CONNECT_TIMEOUT', 45);\nexport const DEFAULT_BROWSER_COMMAND_TIMEOUT = parseEnvTimeout('OPENCLI_BROWSER_COMMAND_TIMEOUT', 60);\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/browser/config.ts#L1-L16","documentation":"parseEnvTimeout reads an integer-milliseconds-style timeout variable (e.g. OPENCLI_BROWSER_CONNECT_TIMEOUT, OPENCLI_BROWSER_COMMAND_TIMEOUT) from the environment. If the variable is set but does not parse as a positive integer, the library logs this warning and falls back to the built-in default (in seconds, hence the 's' suffix in the message). Execution continues with defaultTimeout semantics.","triggerScenarios":"OPENCLI_BROWSER_CONNECT_TIMEOUT or OPENCLI_BROWSER_COMMAND_TIMEOUT is set to a non-numeric string (e.g. '45s', 'one minute'), zero, or a negative number, so parseInt yields NaN or <= 0.","commonSituations":"Users writing '45s' or '1m' in shell profiles (the parser expects a bare integer); quoting mistakes leaving units in the value; locale-formatted numbers; setting the var to 0 intending 'no timeout'.","solutions":["Set the variable to a plain positive integer, e.g. export OPENCLI_BROWSER_CONNECT_TIMEOUT=90.","Remove units ('s', 'ms', 'm') from the value; seconds are implied by the documented default.","Unset the variable entirely to use the built-in default (45s connect timeout).","Check shell startup files (.bashrc/.zshrc) for a stale or malformed export."],"exampleFix":"// before\nexport OPENCLI_BROWSER_CONNECT_TIMEOUT=\"45s\"\n// after\nexport OPENCLI_BROWSER_CONNECT_TIMEOUT=45","handlingStrategy":"validation","validationCode":"const v = process.env.OPENCLI_BROWSER_CONNECT_TIMEOUT;\nconst ok = v === undefined || (/^\\d+$/.test(v) && parseInt(v, 10) > 0);\nif (!ok) throw new Error(`OPENCLI_BROWSER_CONNECT_TIMEOUT must be a positive integer, got \"${v}\"`);","typeGuard":"function isValidTimeout(raw) {\n  if (raw === undefined) return true;\n  const n = Number(raw);\n  return Number.isInteger(n) && n > 0;\n}","tryCatchPattern":null,"preventionTips":["Set timeout env vars as bare positive integers with no units (e.g. 45, not 45s).","Unset the variable to use defaults instead of guessing formats.","Check shell rc files for malformed exports after editing timeouts."],"tags":["environment","configuration","timeout"],"backgroundTag":"invalid-env-var","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}