jackwener/OpenCLI · error · ArgumentError
timeout must be a positive integer
Error message
timeout must be a positive integer
What it means
clis/qwen/image.js throws ArgumentError('timeout must be a positive integer') when the `timeout` kwarg, coerced via Number(kwargs.timeout ?? 180), is not an integer or is <= 0. The library validates this up front because the value is passed to waitForImageUrls as a wait budget in seconds. The default is 180 when the option is omitted.
Source
Thrown at clis/qwen/image.js:121
navigateBefore: false,
defaultFormat: 'plain',
args: [
{ name: 'prompt', required: true, positional: true, help: 'Image prompt to send' },
{ name: 'op', default: '~/Pictures/qianwen', help: 'Output directory' },
{ name: 'new', type: 'boolean', default: true, help: 'Start a new chat before generating (default: true)' },
{ name: 'sd', type: 'boolean', default: false, help: 'Skip download; only show the Qianwen link' },
{ name: 'timeout', type: 'int', default: 180, help: 'Max seconds to wait for the image response' },
],
columns: ['Status', 'File', 'Link'],
func: async (page, kwargs) => {
const prompt = String(kwargs.prompt || '').trim();
if (!prompt) throw new ArgumentError('prompt is required');
const outputDir = String(kwargs.op || '~/Pictures/qianwen').replace(/^~\//, `${os.homedir()}/`);
const startFresh = normalizeBooleanFlag(kwargs.new, true);
const skipDownload = normalizeBooleanFlag(kwargs.sd, false);
const timeout = Number(kwargs.timeout ?? 180);
if (!Number.isInteger(timeout) || timeout <= 0) {
throw new ArgumentError('timeout must be a positive integer');
}
await ensureOnQianwen(page);
await dismissLoginModal(page);
if (startFresh) {
await startNewChat(page);
await dismissLoginModal(page);
}
await setFeatureToggle(page, 'image', true);
await page.wait(0.5);
const send = await sendMessage(page, prompt);
if (!send?.ok) {
if (await hasLoginGate(page)) throw authRequired();
throw new CommandExecutionError(send?.reason || 'Failed to send Qianwen image prompt');
}
// Grab the newest assistant bubble id after send by polling brieflyView on GitHub (pinned to 49907e53dc)
Solutions
- Pass timeout as a plain positive integer in seconds, e.g. --timeout 300
- Remove units or convert them yourself before invoking (90s -> 90)
- Check the resolved value: echo the kwarg; if it is empty or '0', fix the source script/config
- Omit --timeout entirely to use the built-in default of 180 seconds
Example fix
// before node cli.js qwen image --prompt 'a cat' --timeout 90s // after node cli.js qwen image --prompt 'a cat' --timeout 90
Defensive patterns
Strategy: validation
Validate before calling
function isValidTimeout(v) {
const n = Number(v);
return Number.isInteger(n) && n > 0;
}
const timeout = process.argv.timeout ?? 180;
if (!isValidTimeout(timeout)) throw new Error(`timeout must be a positive integer, got: ${JSON.stringify(timeout)}`); Type guard
const isPositiveInt = (v) => typeof v === 'number' && Number.isInteger(v) && v > 0;
Try / catch
try {
await runImageCommand({ prompt, timeout });
} catch (e) {
if (e instanceof ArgumentError && /timeout must be a positive integer/.test(e.message)) {
console.error('Fix: pass --timeout as whole seconds, e.g. --timeout 300');
} else throw e;
} Prevention
- Always pass timeout as plain integer seconds, never with units like '90s'
- Rely on the built-in default (180) unless you have a reason to override
- Validate shell variables feeding the flag are non-empty integers
- Centralize timeout parsing in one helper that rejects non-integers early
When it happens
Trigger: Calling the qianwen image command with --timeout set to a non-numeric string (e.g. '30s', 'abc'), a float (e.g. 2.5), zero, or a negative number. Number() coercion means '' becomes 0 and '0' becomes 0, both rejected.
Common situations: Users writing 'timeout=90s' or '1.5m' expecting duration parsing; shell variables that are empty or unset producing 0; scripts passing fractional defaults; copy-pasted configs where timeout was quoted with units.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- timeout must be a positive integer
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- arxiv ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/586a9bb06baf34cf.
Report an issue: GitHub.