jackwener/OpenCLI · error · ArgumentError
--timeout must be an integer from 1 to 180
Error message
--timeout must be an integer from 1 to 180
What it means
describe validates its --timeout option: it must be an integer between 1 and 180 seconds (default 60), since it bounds how long the automation waits for Midjourney to return four suggestions. Non-integers, strings, or out-of-range values throw this ArgumentError.
Source
Thrown at clis/midjourney/describe.js:38
domain: 'www.midjourney.com',
strategy: Strategy.UI,
browser: true,
siteSession: 'persistent',
navigateBefore: MIDJOURNEY_IMAGINE_URL,
defaultWindowMode: 'background',
args: [
{ name: 'image', positional: true, required: true, help: 'Local PNG, JPEG, WEBP, or GIF (10MB maximum)' },
{ name: 'timeout', type: 'int', default: 60, help: 'Maximum seconds to wait for four suggestions' },
],
columns: ['rank', 'prompt', 'source', 'created_at'],
func: async (page, kwargs) => {
await getMidjourneyAccount(page);
const refs = parseReferenceArgument(kwargs.image, 'image', { multiple: false });
if (refs[0]?.kind !== 'local') throw new ArgumentError('describe currently requires a local image file');
await validateLocalReferences(refs, 'image');
const timeout = Number(kwargs.timeout ?? 60);
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 180) {
throw new ArgumentError('--timeout must be an integer from 1 to 180');
}
if (await isSettingsPanelVisible(page)) await toggleSettingsPanel(page);
const [sourceUrl] = await uploadReferenceLibrary(page, [refs[0].value]);
const baselineGroups = await page.evaluate(() => {
const visible = (node) => {
const rect = node.getBoundingClientRect();
return rect.width > 0 && rect.height > 0;
};
const groups = [];
const markers = [...document.querySelectorAll('div')]
.filter((node) => node.children.length === 0 && node.textContent?.trim() === 'Describe' && visible(node));
for (const marker of markers) {
let root = marker.parentElement;
for (let depth = 0; depth < 16 && root; depth += 1, root = root.parentElement) {
const prompts = [...root.querySelectorAll('p')]
.filter(visible)View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer between 1 and 180 (seconds), e.g. --timeout 120
- Omit the flag to use the default of 60
- Clamp the value in a wrapper: Math.min(180, Math.max(1, Math.round(Number(v))))
- If more than 180s is genuinely needed, raise the limit in describe.js
Example fix
// before opencli midjourney describe --image ./pic.png --timeout 300 // after opencli midjourney describe --image ./pic.png --timeout 180
Defensive patterns
Strategy: validation
Validate before calling
const t = Number(kwargs.timeout ?? 60);
if (!Number.isInteger(t) || t < 1 || t > 180) {
throw new Error(`--timeout must be an integer from 1 to 180, got ${kwargs.timeout}`);
}
await describeCommand.func(page, { ...kwargs, timeout: t }); Type guard
function isValidTimeout(v) {
return Number.isInteger(v) && v >= 1 && v <= 180;
} Try / catch
try {
await describe(page, kwargs);
} catch (err) {
if (err instanceof ArgumentError && err.message.includes('--timeout')) {
console.error('Set --timeout to an integer between 1 and 180 seconds');
} else throw err;
} Prevention
- Clamp: Math.min(180, Math.max(1, Math.round(Number(v))))
- Remember the unit is seconds, not minutes
- Reject non-numeric strings at the parser level
- Omit the flag to accept the 60s default
When it happens
Trigger: --timeout 0, --timeout 200, --timeout 'two minutes', or a float like 1.5 reaching the Number() coercion and integer/range check in describe's func.
Common situations: Users wanting 'no timeout' and passing 0 or a huge number; unit confusion (minutes vs seconds); shells quoting values so '60s' is passed instead of 60.
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 (seconds)
- --timeout must be a positive integer (seconds)
- --timeout must be a positive integer (seconds)
- --timeout must be a positive integer (seconds)
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/224d016f8d8334f4.
Report an issue: GitHub.