jackwener/OpenCLI · error · CommandExecutionError

Weibo compose editor did not appear

Error message

Weibo compose editor did not appear

What it means

After clicking 发微博, the CLI polls every COMPOSE_POLL_MS up to COMPOSE_TIMEOUT_MS for the visible textarea editor. If it never appears, it throws this CommandExecutionError.

Source

Thrown at clis/weibo/publish.js:156

                    // wins over earlier matches. See TEXTAREA_SELECTORS.
                    let last = null;
                    for (const sel of selectors) {
                        for (const t of document.querySelectorAll(sel)) {
                            if (t.offsetParent !== null) last = t;
                        }
                    }
                    if (!last) return { found: false };
                    return { found: true, visible: true, rectTop: last.getBoundingClientRect().top };
                })(${JSON.stringify(TEXTAREA_SELECTORS)})
            `);
            if (result?.found && result.visible && result.rectTop >= 0) {
                editorFound = true;
                break;
            }
            await page.wait({ time: COMPOSE_POLL_MS / 1000 });
        }
        if (!editorFound) {
            throw new CommandExecutionError('Weibo compose editor did not appear');
        }

        // Step 5: Upload images first (before text to avoid editor reset)
        if (absPaths.length > 0) {
            if (!page.setFileInput) {
                throw new CommandExecutionError('Browser extension does not support file upload. Please update the extension.');
            }

            // Find the file input
            const fileInputFound = await page.evaluate(`
                () => {
                    const input = document.querySelector('input[type="file"][class*="_file_"]');
                    return !!input;
                }
            `);
            if (!fileInputFound) {
                throw new CommandExecutionError('Could not find image file input on Weibo compose page. UI may have changed.');
            }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry; transient slowness often succeeds on a second run with a faster connection
  2. Dismiss any overlays/dialogs and ensure only one compose flow is open
  3. Update the library if Weibo changed the editor's class names (textarea._input_13iqr_8 pattern is CSS-module hashed and unstable across releases)
  4. Increase patience by checking network conditions; the timeout is hard-coded in clis/weibo/publish.js

Example fix

// before
weibo publish --text "hi"   # editor never appeared on slow link
// after
# ensure stable network / retry
weibo publish --text "hi"
Defensive patterns

Strategy: retry

Validate before calling

// run only on a reliable connection; editor must hydrate within COMPOSE_TIMEOUT_MS
if (process.env.SLOW_NETWORK) {
  console.warn('editor may not appear in time on slow networks');
}

Try / catch

try {
  await cli.run(['weibo', 'publish', '--text', text]);
} catch (err) {
  if (/compose editor did not appear/.test(err.message)) {
    await new Promise(r => setTimeout(r, 5000));
    await cli.run(['weibo', 'publish', '--text', text]); // retry once
  } else throw err;
}

Prevention

When it happens

Trigger: The compose editor failed to open after the button click — click silently swallowed, editor rendered without matching textarea._input_* selector, slow network/JS preventing hydration within the timeout.

Common situations: Slow connections or heavy pages exceeding COMPOSE_TIMEOUT_MS; Weibo UI changes renaming editor CSS-module classes; editor blocked by an interstitial dialog.

Related errors


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