jackwener/OpenCLI · error · ArgumentError
delayMaxMs
Error message
delayMaxMs
What it means
The grok export-all command accepts delayMinMs and delayMaxMs, a randomized 'polite delay' range applied after each conversation page loads (to avoid rate limiting). Both are individually validated to be 0-60000, and an extra cross-field check enforces that the upper bound of the range is not lower than the lower bound. An ArgumentError('delayMaxMs', 'must be >= delayMinMs') is thrown when the user supplies a max that is smaller than the min.
Source
Thrown at clis/grok/export-all.js:370
{ name: 'offset', type: 'int', default: 0, help: 'Skip this many conversations before exporting' },
{ name: 'manifestPath', type: 'string', default: '', help: 'Optional grok/export JSON manifest path; skips history dialog and visits listed /c pages directly' },
{ name: 'maxScrolls', type: 'int', default: 80, help: 'Max history-list scroll rounds when limit is 0 (max 500)' },
{ name: 'pageScrolls', type: 'int', default: 30, help: 'Max per-conversation scroll-to-bottom rounds (max 200)' },
{ name: 'pageTimeoutMs', type: 'int', default: 30000, help: 'Max wait for each conversation page to show messages' },
{ name: 'delayMinMs', type: 'int', default: 0, help: 'Minimum polite delay after a conversation page loads' },
{ name: 'delayMaxMs', type: 'int', default: 5000, help: 'Maximum polite delay after a conversation page loads' },
],
columns: ['index', 'id', 'title', 'date', 'url', 'status', 'messageCount', 'error', 'messagesJson'],
func: async (page, kwargs) => {
const limit = normalizeInteger(kwargs.limit, 0, 'limit', { min: 0 });
const offset = normalizeInteger(kwargs.offset, 0, 'offset', { min: 0 });
const maxScrolls = normalizeInteger(kwargs.maxScrolls, 80, 'maxScrolls', { min: 1, max: 500 });
const pageScrolls = normalizeInteger(kwargs.pageScrolls, 30, 'pageScrolls', { min: 1, max: 200 });
const pageTimeoutMs = normalizeInteger(kwargs.pageTimeoutMs, 30000, 'pageTimeoutMs', { min: 5000, max: 180000 });
const delayMinMs = normalizeInteger(kwargs.delayMinMs, 0, 'delayMinMs', { min: 0, max: 60000 });
const delayMaxMs = normalizeInteger(kwargs.delayMaxMs, 5000, 'delayMaxMs', { min: 0, max: 60000 });
if (delayMaxMs < delayMinMs) {
throw new ArgumentError('delayMaxMs', 'must be >= delayMinMs');
}
const conversations = readManifest(kwargs.manifestPath, { offset, limit })
|| await collectHistory(page, { offset, limit, maxScrolls });
const rows = [];
for (let i = 0; i < conversations.length; i += 1) {
const conversation = conversations[i];
const transcript = await readConversation(page, conversation, {
pageTimeoutMs,
pageScrolls,
delayMinMs,
delayMaxMs,
});
rows.push({
index: offset + i + 1,
id: conversation.id,
title: conversation.title || null,
date: conversation.date || null,View on GitHub (pinned to 49907e53dc)
Solutions
- Set --delay-max-ms to a value greater than or equal to --delay-min-ms (e.g. --delay-min-ms 1000 --delay-max-ms 5000).
- If you want a fixed delay with no jitter, set both flags to the same value (e.g. --delay-min-ms 2000 --delay-max-ms 2000).
- Omit both flags to use the defaults (min 0, max 5000).
Example fix
// before opencli grok export-all --delay-min-ms 4000 --delay-max-ms 1000 // after opencli grok export-all --delay-min-ms 1000 --delay-max-ms 4000
Defensive patterns
Strategy: validation
Validate before calling
const delayMinMs = Number(process.env.DELAY_MIN_MS ?? 0);
const delayMaxMs = Number(process.env.DELAY_MAX_MS ?? 5000);
if (!Number.isInteger(delayMinMs) || !Number.isInteger(delayMaxMs) ||
delayMinMs < 0 || delayMaxMs > 60000 || delayMaxMs < delayMinMs) {
throw new RangeError('delayMaxMs must be an integer in [delayMinMs, 60000]');
} Type guard
function isValidDelayRange(min, max) {
return Number.isInteger(min) && Number.isInteger(max) &&
min >= 0 && max <= 60000 && max >= min;
} Prevention
- Keep delay flags together in config and validate min <= max at load time, not at CLI invocation.
- When you want a fixed delay, set both flags to the same value.
- Prefer omitting the flags and using the safe defaults (0-5000) unless you need custom pacing.
When it happens
Trigger: Running `opencli grok export-all --delay-min-ms 3000 --delay-max-ms 1000` (or any kwargs.delayMaxMs < kwargs.delayMinMs) at clis/grok/export-all.js:370. Both values must pass their individual 0..60000 range check first, then fail the comparison.
Common situations: Copy-pasting a delay config from another tool with swapped argument names; hand-editing a defaults file to shrink the max delay but forgetting the min; misunderstanding which flag is the lower vs upper bound of the range; setting delayMinMs after previously setting a low delayMaxMs.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8f9a12c25cb13f41.
Report an issue: GitHub.