jackwener/OpenCLI · warning

[warn] Total image payload is ${(totalBytes / 1024 / 1024).t

Error message

[warn] Total image payload is ${(totalBytes / 1024 / 1024).toFixed(1)}MB (base64). This may fail with the browser bridge. Update the extension to v1.6+ for CDP-based upload, or compress images before publishing.

What it means

uploadImages warns when the combined base64 size of all images to publish exceeds ~500KB, because large JSON payloads may fail through the browser bridge's page.evaluate on extensions older than v1.6 (no CDP-based upload).

Source

Thrown at clis/xiaohongshu/publish.js:189

            const msg = err instanceof Error ? err.message : String(err);
            if (msg.includes('Unknown action') || msg.includes('not supported') || msg.includes('Not allowed')) {
                // Extension too old — fall through to legacy base64 method
            }
            else {
                return { ok: false, count: 0, error: msg };
            }
        }
    }
    // ── Fallback: legacy base64 DataTransfer injection ─────────────────
    const images = absPaths.map((absPath) => {
        const base64 = fs.readFileSync(absPath).toString('base64');
        const ext = path.extname(absPath).toLowerCase();
        return { name: path.basename(absPath), mimeType: SUPPORTED_EXTENSIONS[ext], base64 };
    });
    // Warn if total payload is large — this may fail with older extensions
    const totalBytes = images.reduce((sum, img) => sum + img.base64.length, 0);
    if (totalBytes > 500_000) {
        console.warn(`[warn] Total image payload is ${(totalBytes / 1024 / 1024).toFixed(1)}MB (base64). ` +
            'This may fail with the browser bridge. Update the extension to v1.6+ for CDP-based upload, ' +
            'or compress images before publishing.');
    }
    const payload = JSON.stringify(images);
    return page.evaluate(`
    (async () => {
      const images = ${payload};

      const inputs = Array.from(document.querySelectorAll('input[type="file"]'));
      const input = inputs.find(el => {
        const accept = el.getAttribute('accept') || '';
        return (
          accept.includes('image') ||
          accept.includes('.jpg') ||
          accept.includes('.jpeg') ||
          accept.includes('.png') ||
          accept.includes('.gif') ||
          accept.includes('.webp')

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update the browser extension to v1.6+ for CDP-based upload
  2. Compress or resize each image before publishing (JPEG/WebP, ~1280px)
  3. Reduce the number of images per publish and split into multiple notes if needed
  4. If publish fails after the warning, retry with smaller images rather than retrying identical payloads

Example fix

// before
opencli xiaohongshu publish --images a.png b.png c.png  # 6MB total, warn
// after: pre-compress
for f in a b c; do npx sharp -i $f.png -o $f.jpg resize 1280; done
opencli xiaohongshu publish --images a.jpg b.jpg c.jpg
Defensive patterns

Strategy: validation

Validate before calling

const total = images.reduce((s, f) => s + fs.statSync(f).size, 0);
if (total * 4 / 3 > 500_000) {
  console.warn('Total payload too large for browser bridge; compress images.');
}

Try / catch

try {
  await publish(page, note);
} catch (err) {
  if (/upload|payload|evaluate/i.test(err.message)) {
    await publish(page, { ...note, images: note.images.map(compressImage) });
  }
}

Prevention

When it happens

Trigger: Publishing a Xiaohongshu note where sum of base64 lengths across all attached images exceeds 500,000 characters with a pre-v1.6 extension installed.

Common situations: Publishing multiple high-resolution photos at once, images not compressed beforehand, older extension, multi-image notes where each image alone is under the limit but the total is not.

Related errors


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