jackwener/OpenCLI · error · CommandExecutionError

Failed to fetch TikTok Studio item_list: ${getErrorMessage(e

Error message

Failed to fetch TikTok Studio item_list: ${getErrorMessage(error)}

What it means

fetchCreatorVideosPage runs an in-page fetch against TikTok Studio's item_list API inside the browser context. If page.evaluate itself rejects (script threw, page crashed, navigation destroyed the context), the catch rethrows it as a CommandExecutionError wrapping the original message. This is the top-level failure boundary for the item_list RPC.

Source

Thrown at clis/tiktok/creator-videos.js:188

    const url = username
        ? `https://www.tiktok.com/@${encodeURIComponent(username)}/video/${encodeURIComponent(videoId)}`
        : '';
    return {
        video_id: videoId,
        title: String(item.desc ?? item.title ?? '').replace(/\s+/g, ' ').trim(),
        date: formatDate(item.post_time ?? item.create_time ?? item.schedule_time),
        views: normalizeNumber(item.play_count),
        likes: normalizeNumber(item.like_count),
        comments: normalizeNumber(item.comment_count),
        saves: normalizeNumber(item.favorite_count),
        shares: normalizeNumber(item.share_count),
        url,
    };
}

async function fetchCreatorVideosPage(page, cursor, size) {
    const result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size))).catch((error) => {
        throw new CommandExecutionError(`Failed to fetch TikTok Studio item_list: ${getErrorMessage(error)}`);
    });
    if (!result || typeof result !== 'object') {
        throw new CommandExecutionError('TikTok Studio item_list returned an unreadable response');
    }
    if (result.networkError) {
        throw new CommandExecutionError(`TikTok Studio item_list network failure: ${result.networkError}`);
    }
    if (result.status === 401 || result.status === 403) {
        throw new AuthRequiredError('www.tiktok.com', `TikTok Studio item_list requires login (HTTP ${result.status})`);
    }
    if (!result.ok) {
        const detail = result.parseError
            ? `invalid JSON (${result.parseError})`
            : `HTTP ${result.status || 0}${result.statusText ? ` ${result.statusText}` : ''}`;
        throw new CommandExecutionError(`TikTok Studio item_list failed: ${detail}`, result.text ? `Response preview: ${result.text}` : undefined);
    }
    const payload = unwrapPayload(result.data);
    assertApiSuccess(payload);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the wrapped getErrorMessage(error) detail to identify the root cause (context destroyed vs script throw)
  2. Ensure the Chrome profile is logged in to TikTok Studio before running the command
  3. Re-run the command; transient navigation or tab crashes are often one-off
  4. Update Puppeteer/Playwright and keep the page idle (no concurrent navigation) during the call
  5. Catch CommandExecutionError in the caller and retry with a fresh page

Example fix

// before
const result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size)));
// after
let result;
try {
  result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size)));
} catch (error) {
  await sleep(1000); // or reopen the page
  result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size)));
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!page || page.isClosed?.()) throw new Error('Page closed before fetching creator videos');

Type guard

function isFetchResult(v) { return !!v && typeof v === 'object'; }

Try / catch

try {
  rows = await listCreatorVideos(page, opts);
} catch (e) {
  if (e instanceof CommandExecutionError && /item_list/.test(e.message)) {
    await sleep(2000); rows = await listCreatorVideos(page, opts); // one retry
  } else throw e;
}

Prevention

When it happens

Trigger: page.evaluate rejects: the injected fetch script throws a non-network error, the page navigates/reloads mid-call, the Puppeteer/Playwright page or context is closed, or the browser tab crashed during the request.

Common situations: Chrome profile closed mid-run, TikTok triggering a full page navigation (login redirect) while the script runs, headless detection killing the tab, or long page.evaluate exceeding browser stability on heavy Studio pages.

Related errors


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