jackwener/OpenCLI · error · CommandExecutionError

Failed to open Instagram reel composer

Error message

Failed to open Instagram reel composer

What it means

If ensureComposerOpen's in-page script returns a non-ok result whose reason is not 'auth', the library throws CommandExecutionError 'Failed to open Instagram reel composer'. It means the composer could not be opened for a non-login reason — page structure unexpected, navigation failed, or Instagram served an interstitial.

Source

Thrown at clis/instagram/reel.js:73

    const baseName = path.basename(filePath);
    if (/^[a-zA-Z0-9._-]+$/.test(baseName)) {
        return { originalPath: filePath, uploadPath: filePath };
    }
    const uploadPath = buildSafeTempVideoPath(filePath);
    fs.copyFileSync(filePath, uploadPath);
    return {
        originalPath: filePath,
        uploadPath,
        cleanupPath: uploadPath,
    };
}
async function ensureComposerOpen(page) {
    const result = await page.evaluate(buildEnsureComposerOpenJs());
    if (!result?.ok) {
        if (result?.reason === 'auth') {
            throw new AuthRequiredError('www.instagram.com', 'Instagram login required before posting a reel');
        }
        throw new CommandExecutionError('Failed to open Instagram reel composer');
    }
    for (let attempt = 0; attempt < 12; attempt += 1) {
        const ready = await page.evaluate(`
      (() => {
        const isVisible = (el) => {
          if (!(el instanceof HTMLElement)) return false;
          const style = window.getComputedStyle(el);
          const rect = el.getBoundingClientRect();
          return style.display !== 'none'
            && style.visibility !== 'hidden'
            && rect.width > 0
            && rect.height > 0;
        };
        const inputs = Array.from(document.querySelectorAll('input[type="file"]'))
          .filter((el) => el instanceof HTMLInputElement)
          .filter((el) => {
            const dialog = el.closest('[role="dialog"]');
            return dialog instanceof HTMLElement && isVisible(dialog);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after confirming the page is on instagram.com and fully loaded.
  2. Log in and check the account can post manually in the same browser session (look for restrictions/blocks).
  3. Update the CLI/library if Instagram's DOM changed (the composer-detection script may be outdated).
  4. Slow down / back off if rate-limited; avoid rapid repeated postings.

Example fix

// before
await ensureComposerOpen(page); // page may be on an error page
// after
await gotoInstagramHome(page);
await page.wait({ time: 2 });
await ensureComposerOpen(page);
Defensive patterns

Strategy: retry

Validate before calling

await gotoInstagramHome(page);
if (!page.url().includes('instagram.com')) throw new Error('Not on instagram.com; navigation failed');

Try / catch

try { await reel(args); } catch (e) { if (e.message.includes('Failed to open Instagram reel composer')) { await new Promise(r => setTimeout(r, 5000)); await gotoInstagramHome(page); return reel(args); } throw e; }

Prevention

When it happens

Trigger: page.evaluate returning ok:false with reasons like DOM mismatch (Instagram markup changed), page on a wrong URL/error page, rate-limit or 'try again later' interstitial, or the evaluate itself failing softly.

Common situations: Instagram UI/A/B test changed composer markup, account flagged with restrictions blocking posting, network hiccup during navigation, or landing on instagram.com variant pages.

Related errors


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