jackwener/OpenCLI · error · TimeoutError

twitter retweet confirmation

Error message

twitter retweet confirmation

What it means

TimeoutError thrown after the retweet click script could not confirm the retweet within 1 attempt/timeout window. The library intentionally does not retry because the click may have actually succeeded, making a blind retry risky (double retweet or un-retweet). It surfaces the underlying script failure message plus guidance to verify the tweet manually.

Source

Thrown at clis/twitter/retweet.js:88

            }
            writeStarted = true;
            confirmBtn.click();
            await new Promise(r => setTimeout(r, 1000));

            // Verify success by checking if the 'unretweet' button appeared
            const verifyArticle = findTargetArticle() || targetArticle;
            const verifyBtn = verifyArticle?.querySelector('[data-testid="unretweet"]');
            if (verifyBtn) {
                return { ok: true, message: 'Tweet successfully retweeted.' };
            } else {
                return { ok: false, unconfirmed: true, message: 'Retweet action was initiated but UI did not update as expected.' };
            }
        } catch (e) {
            return { ok: false, unconfirmed: writeStarted, message: e.toString() };
        }
    })()`);
        if (result.unconfirmed) {
            throw new TimeoutError('twitter retweet confirmation', 1, `${result.message} Check the tweet before retrying; the retweet may already have succeeded.`);
        }
        if (!result.ok) {
            throw new CommandExecutionError(result.message, 'Nothing changed. Open the tweet in the browser and retry.');
        }
        await page.wait(2);
        return [{
                status: 'success',
                message: result.message
            }];
    }
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the tweet in the browser and check whether the retweet already succeeded before doing anything else
  2. Retry the retweet command once the page loads normally; if already retweeted, undo or skip
  3. Re-run after `opencli` login/cookie refresh if the page appeared logged out
  4. Update opencli if X changed its DOM and the selector consistently fails

Example fix

// before
await opencli.twitter.retweet(url); // TimeoutError: retweet confirmation
// after
const status = await checkTweetRetweeted(url); // verify manually/via API first
if (!status.retweeted) await opencli.twitter.retweet(url);
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the page is loaded and logged in before retweeting
const cookies = await page.getCookies({ url: 'https://x.com' });
if (!cookies.some((c) => c.name === 'ct0')) throw new Error('Not logged into x.com');

Type guard

function isTimeoutError(e) { return e && e.name === 'TimeoutError'; }

Try / catch

try {
  await opencli.twitter.retweet(url);
} catch (e) {
  if (isTimeoutError(e)) {
    // DO NOT blind-retry: check the tweet state first, then decide
    const done = await verifyRetweetedInBrowser(url);
    if (!done) await opencli.twitter.retweet(url);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `opencli twitter retweet <url>` when the in-page script that clicks the retweet button and awaits confirmation times out or throws — e.g. slow page load, retweet button selector missing, UI layout change, or network stall during the confirmation window.

Common situations: Slow/unstable connection to x.com, X's UI serving a different retweet dialog (e.g. logged-out state or A/B test), page not fully settled before clicking, or the tweet already retweeted so no confirmation appears.

Related errors


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