jackwener/OpenCLI · error · CommandExecutionError

Midjourney ${kind} download did not complete: ${downloaded?.

Error message

Midjourney ${kind} download did not complete: ${downloaded?.error || downloaded?.state || 'unknown'}

What it means

A CommandExecutionError thrown when page.waitForDownload resolves but the result is not a successful complete download — either downloaded.downloaded is falsy, state is not 'complete', or no filename was reported. The message interpolates the bridge's error field or state so you can see why the download failed.

Source

Thrown at clis/midjourney/utils.js:760

  await page.wait({ selector: 'video[src]', timeout: 20 });
  await page.click('button[title="Options"]');
  await page.wait(0.3);
  const marked = unwrapEvaluateResult(await page.evaluate((label) => {
    document.querySelectorAll('[data-opencli-video-download]').forEach((node) => node.removeAttribute('data-opencli-video-download'));
    const button = [...document.querySelectorAll('button[role="menuitem"],button')]
      .find((node) => node.textContent?.trim() === label && node.getBoundingClientRect().width > 0);
    if (!button) return false;
    button.setAttribute('data-opencli-video-download', '1');
    return true;
  }, config.label));
  if (!marked) throw new CommandExecutionError(`Midjourney did not expose "${config.label}" for video ${jobId}`);
  await page.click('[data-opencli-video-download="1"]');
  if (typeof page.waitForDownload !== 'function') {
    throw new CommandExecutionError('Browser Bridge download lifecycle support is required for social video/GIF export');
  }
  const downloaded = await page.waitForDownload(jobId, 60_000);
  if (!downloaded?.downloaded || downloaded.state !== 'complete' || !downloaded.filename) {
    throw new CommandExecutionError(`Midjourney ${kind} download did not complete: ${downloaded?.error || downloaded?.state || 'unknown'}`);
  }
  const sourcePath = path.resolve(String(downloaded.filename));
  const sourceStat = await fs.stat(sourcePath).catch(() => null);
  if (!sourceStat?.isFile() || sourceStat.size <= 0) {
    throw new CommandExecutionError(`Browser reported a completed download but the file is missing: ${sourcePath}`);
  }
  const handle = await fs.open(sourcePath, 'r');
  let actualMime;
  try {
    const header = Buffer.alloc(16);
    const { bytesRead } = await handle.read(header, 0, header.length, 0);
    actualMime = sniffMediaMime(header.subarray(0, bytesRead));
  } finally {
    await handle.close();
  }
  if (actualMime !== config.mime) {
    throw new CommandExecutionError(
      `Midjourney ${kind} returned invalid media bytes; expected ${config.mime}, detected ${actualMime || 'unknown'}`,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Increase the 60_000ms timeout for large/slow downloads
  2. Re-authenticate the Midjourney browser session and retry
  3. Check free disk space and write permissions on the browser's download directory
  4. Inspect the interpolated state/error in the message to target the specific failure (timeout vs failed)
  5. Retry the command — transient CDN slowness commonly causes timeouts
Defensive patterns

Strategy: retry

Type guard

function isCompletedDownload(d) {
  return Boolean(d && d.downloaded && d.state === 'complete' && d.filename);
}

Try / catch

try {
  await downloadRenderedVideo(page, jobId, i, kind, outDir);
} catch (err) {
  if (err.message.includes('download did not complete')) {
    log.warn(`Download incomplete (${err.message}), retrying...`);
    await downloadRenderedVideo(page, jobId, i, kind, outDir, true);
  } else throw err;
}

Prevention

When it happens

Trigger: The 60-second waitForDownload window expires (state 'timeout'), the browser cancels or fails the download (state 'failed'/'cancelled'), or the bridge returns an error string in downloaded.error.

Common situations: Large GIF/social renders exceeding 60s on slow connections; Midjourney auth expiring mid-download so the click triggers a login page instead; user closing the browser tab during download; disk-full or permission-denied in the browser's download directory.

Related errors


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