jackwener/OpenCLI · error · TimeoutError

twitter followers pagination

Error message

twitter followers pagination

What it means

TimeoutError with command id 'twitter followers pagination'. The followers list used infinite scrolling: after receiving a page with a continuation (Bottom/ShowMore) cursor, the command auto-scrolls the page and waits up to CAPTURE_TIMEOUT_SECONDS (10s) for the next Followers GraphQL response to be intercepted. If no response is captured in that window, this error is thrown, reporting how many follower rows were collected so far.

Source

Thrown at clis/twitter/followers.js:185

                    if (!seen.has(user.screen_name)) {
                        seen.add(user.screen_name);
                        allFollowers.push(user);
                    }
                }
                cursor = nextCursor;
            }
        };

        await consumeCaptured();
        while (allFollowers.length < limit && cursor && pages < MAX_PAGINATION_PAGES) {
            const beforeCount = allFollowers.length;
            const beforeCursor = cursor;
            await page.autoScroll({ times: 1, delayMs: 500 });
            try {
                await page.waitForCapture(CAPTURE_TIMEOUT_SECONDS);
            }
            catch {
                throw new TimeoutError('twitter followers pagination', CAPTURE_TIMEOUT_SECONDS, `Twitter returned a continuation cursor after ${allFollowers.length} rows, but the next Followers response was not observed.`);
            }
            await consumeCaptured();
            pages++;
            if (allFollowers.length === beforeCount && cursor === beforeCursor) {
                throw new CommandExecutionError('Twitter followers pagination repeated a cursor without returning new users');
            }
        }
        if (allFollowers.length < limit && cursor && pages >= MAX_PAGINATION_PAGES) {
            throw new CommandExecutionError(`Twitter followers pagination exceeded ${MAX_PAGINATION_PAGES} pages before cursor exhaustion`);
        }
        if (allFollowers.length === 0) {
            if (looksLikePrivateTwitterTimeline(lastRawResponse)) {
                throw new EmptyResultError('twitter followers', `No follower data returned for @${targetUser} (the target account may have set their followers list to private)`);
            }
            throw new EmptyResultError('twitter followers', `No followers found for @${targetUser}`);
        }
        return allFollowers.slice(0, limit);
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command — the timeout is per-page and often transient; reduce --limit so fewer pagination rounds are needed.
  2. Re-run with a fresh logged-in browser session to clear silent X rate limiting on the Followers endpoint.
  3. Check network connectivity and keep the browser tab focused while the command runs.
  4. If timeouts persist at a specific row count, the target account may be rate-limiting followers visibility; try again later or fetch a smaller limit.

Example fix

// before
opencli twitter followers @someuser --limit 1000
// after
opencli twitter followers @someuser --limit 200   # fewer pagination rounds, less likely to hit capture timeout
Defensive patterns

Strategy: retry

Validate before calling

const limit = Number(process.argv.includes('--limit') ? /* parsed */ 200 : 50);
if (!Number.isInteger(limit) || limit <= 0) throw new Error('limit must be a positive integer');
// keep limit modest (<= a few hundred) so pagination finishes well within capture timeouts

Type guard

function isPositiveInt(v) { return Number.isInteger(v) && v > 0; }

Try / catch

import { TimeoutError } from '@jackwener/opencli/errors';
for (let attempt = 1; attempt <= 3; attempt++) {
  try { return await opencli.twitter.followers(user, { limit }); }
  catch (e) { if (e instanceof TimeoutError && attempt < 3) continue; throw e; }
}

Prevention

When it happens

Trigger: Twitter returned a continuation cursor for the Followers timeline (so pagination continues), but after page.autoScroll({times:1, delayMs:500}) no new Followers GraphQL response was captured within 10 seconds — e.g. the scroll did not trigger the next request, X rate-limited/deprioritized the endpoint, or the page was in a stale/error state.

Common situations: Slow network or heavily throttled X sessions where responses take longer than 10s; X silently rate-limiting the Followers GraphQL endpoint after many pages; the browser tab was backgrounded so autoScroll stalls; an X A/B UI change stops infinite scroll from firing the request; large limits (hundreds of followers) requiring many sequential pages.

Related errors


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