jackwener/OpenCLI · error · CommandExecutionError

Twitter likes output file is missing for resume state: ${out

Error message

Twitter likes output file is missing for resume state: ${outputFile}

What it means

CommandExecutionError thrown during --resume validation: the resume state file records a positive count of previously fetched likes, but the JSONL output file it references no longer exists on disk. The library refuses to resume because it cannot rebuild a consistent archive state from a missing file.

Source

Thrown at clis/twitter/likes.js:277

        // Get userId from screen_name
        const userId = unwrapBrowserResult(await page.evaluate(`async () => {
      const screenName = ${JSON.stringify(username)};
      const url = ${JSON.stringify(buildUserByScreenNameQueryUrl(userByScreenNameQueryId, username))};
      const resp = await fetch(url, { headers: ${headers}, credentials: 'include' });
      if (!resp.ok) return null;
      const d = await resp.json();
      return d.data?.user?.result?.rest_id || null;
    }`));
        if (!userId) {
            throw new CommandExecutionError(`Could not find user @${username}`);
        }
        const resumed = fetchAll ? readResumeFile(resumeFile, {
            source: 'likes',
            username,
            outputFile: useOutputFile ? outputFile : null,
        }) : null;
        if (useOutputFile && resumed && resumed.count > 0 && !fs.existsSync(outputFile)) {
            throw new CommandExecutionError(`Twitter likes output file is missing for resume state: ${outputFile}`);
        }
        if (useOutputFile && !resumed && fs.existsSync(outputFile)) {
            throw new ArgumentError(`Refusing to overwrite existing Twitter likes output file: ${outputFile}`);
        }
        const allTweets = useOutputFile ? [] : (resumed?.tweets ? [...resumed.tweets] : []);
        const jsonlState = useOutputFile ? loadJsonlArchiveState(outputFile) : null;
        const seen = useOutputFile
            ? jsonlState.seen
            : new Set(allTweets.map((tweet) => tweet?.id).filter(Boolean));
        if (useOutputFile && resumed && jsonlState.count !== resumed.count) {
            throw new CommandExecutionError(`Twitter likes output file has ${jsonlState.count} record(s), expected resume count ${resumed.count}`);
        }
        let outputCount = useOutputFile ? jsonlState.count : 0;
        let cursor = resumed?.cursor || null;
        let lastRawResponse = null;
        let pages = 0;
        let exhausted = false;
        // Runaway guard only; --limit/--all and cursor exhaustion control normal pagination.

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Delete the stale resume file (e.g. the .resume/.state sidecar next to the output) and re-run from scratch.
  2. Re-run with the exact same --output path used in the original run so the existing JSONL is found.
  3. Restore the deleted/moved output file, then resume again.
  4. Run from the same working directory if the output path was relative.

Example fix

// before
$ cli twitter likes @user --all --resume  # output file was deleted
// after
$ rm .twitter-likes-user.resume
$ cli twitter likes @user --all --output likes.jsonl
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('node:fs');
if (resumeExists() && !fs.existsSync(outputFile)) {
  fs.rmSync(resumeFile); // clear stale resume state before re-running
}

Type guard

null

Try / catch

try {
  await cli.twitter.likes({ username, all: true, resume: true });
} catch (e) {
  if (/output file is missing for resume state/.test(e.message)) {
    deleteResumeFile(); // then re-run fresh
  } else throw e;
}

Prevention

When it happens

Trigger: fetchAll is set, readResumeFile returns resumed.count > 0 and useOutputFile is true, but fs.existsSync(outputFile) is false at clis/twitter/likes.js:277.

Common situations: The user deleted or moved the output JSONL between runs while keeping the hidden resume file; output written to a different --output path than the original run; running from a different working directory with a relative output path.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/bcad27bdc4d159bc. Report an issue: GitHub.