jackwener/OpenCLI · error · TimeoutError

Midjourney reference upload

Error message

Midjourney reference upload

What it means

TimeoutError thrown when fewer images than the number of local paths uploaded were detected within 30 seconds. The function compares visible image sources before and after upload and counts brand-new URLs as uploaded images.

Source

Thrown at clis/midjourney/utils.js:1137

  let capturedSources = [];
  if (captureReady) {
    try {
      await page.waitForCapture(10);
      capturedSources = uploadedStorageUrlsFromCaptures(await page.getInterceptedRequests());
    } catch {}
  }

  let newSources = [];
  for (let attempt = 0; attempt < 30; attempt += 1) {
    await page.wait(1);
    const currentSources = await visibleImageSources(page);
    const capturedVisible = capturedSources.filter((url) => currentSources.includes(url));
    if (capturedVisible.length >= localPaths.length) return capturedVisible.slice(0, localPaths.length);
    newSources = currentSources.filter((url) => !before.has(url));
    if (newSources.length >= localPaths.length) break;
  }
  if (newSources.length < localPaths.length) {
    throw new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);
  }

  return newSources.slice(0, localPaths.length);
}

async function openEndFramePicker(page) {
  const marked = unwrapEvaluateResult(await page.evaluate(() => {
    document.querySelectorAll('[data-opencli-end-frame-picker]').forEach((node) => {
      node.removeAttribute('data-opencli-end-frame-picker');
    });
    const label = [...document.querySelectorAll('div')]
      .find((node) => node.children.length === 0 && node.textContent?.trim() === 'End Frame');
    let target = label;
    for (let depth = 0; depth < 7 && target; depth += 1, target = target.parentElement) {
      if (String(target.className).includes('cursor-pointer')) {
        target.setAttribute('data-opencli-end-frame-picker', '1');
        return true;
      }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the upload; transient slowness is the most common cause.
  2. Check for duplicate local files — Midjourney may reuse an existing image URL so it won't count as 'new'.
  3. Increase the 30s timeout or poll interval for slow connections.
  4. Verify each file uploads individually and confirm counts before batch uploads.

Example fix

// before
throw new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);
// after
if (newSources.length < localPaths.length) {
  await retryUpload(page, localPaths);
  throw new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);
}
Defensive patterns

Strategy: retry

Validate before calling

if (!localPaths.length) return [];
const unique = [...new Set(localPaths.map(p => require('fs').realpathSync(p)))];
if (unique.length !== localPaths.length) console.warn('duplicate images may not count as new uploads');

Try / catch

try {
  await uploadReferenceLibrary(page, paths);
} catch (err) {
  if (err.name === 'TimeoutError') {
    await page.wait(5);
    await uploadReferenceLibrary(page, paths);
  } else throw err;
}

Prevention

When it happens

Trigger: uploadReferenceLibrary waits 30s polling visibleImageSources; newSources.length < localPaths.length at the deadline (e.g. 2 files given but only 1 new image URL appeared).

Common situations: Midjourney deduplicates identical images already uploaded; uploads partially failed; slow network/CPU caused thumbnails not to render in 30s; the page was mid-navigation.

Related errors


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