jackwener/OpenCLI · warning · EmptyResultError

TikTok returned no friend suggestions

Error message

TikTok returned no friend suggestions

What it means

listFriends' final guard: if rows is not a non-empty array after the page script completes, it throws EmptyResultError('tiktok friends', 'TikTok returned no friend suggestions'). This ensures the command fails with a typed empty-result error rather than returning an empty success value.

Source

Thrown at clis/tiktok/friends.js:122

`;
}

async function listFriends(page, args) {
    const limit = requireLimit(args.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });
    await page.goto('https://www.tiktok.com/friends', { waitUntil: 'load', settleMs: 5000 });
    let rows;
    try {
        rows = await page.evaluate(buildFriendsScript(limit));
    } catch (error) {
        throwTikTokPageContextError(error, {
            authMessage: 'TikTok requires browser access to load friend suggestions',
            emptyPattern: /No friend suggestions/,
            emptyTarget: 'tiktok friends',
            failureMessage: 'Failed to load TikTok friend suggestions',
        });
    }
    if (!Array.isArray(rows) || rows.length === 0) {
        throw new EmptyResultError('tiktok friends', 'TikTok returned no friend suggestions');
    }
    return rows;
}

export const friendsCommand = cli({
    site: 'tiktok',
    name: 'friends',
    access: 'read',
    description: 'Get TikTok friend / who-to-follow suggestions via page-context APIs',
    domain: 'www.tiktok.com',
    strategy: Strategy.COOKIE,
    browser: true,
    args: [
        { name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of suggestions (max ${MAX_LIMIT})` },
    ],
    columns: ['index', 'username', 'name', 'secUid', 'verified', 'followers', 'following', 'url'],
    func: listFriends,
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Catch EmptyResultError and default to an empty suggestions list in your code.
  2. Verify in a browser whether tiktok.com actually shows suggestions for this account.
  3. Refresh the login session and retry — recommendation quality depends on a valid session.
  4. Upgrade the library if TikTok changed the recommend-user response shape.
  5. Treat a consistent empty result for an active account as a signal to check for rate limiting or region blocks.

Example fix

// before
const rows = await friendsCommand({ limit: 20 });
// after
try {
  rows = await friendsCommand({ limit: 20 });
} catch (e) {
  if (e instanceof EmptyResultError) rows = [];
  else throw e;
}
Defensive patterns

Strategy: try-catch

Type guard

function isEmptyResult(e) {
  return e instanceof EmptyResultError;
}

Try / catch

let rows = [];
try {
  rows = await friendsCommand({ limit });
} catch (e) {
  if (e instanceof EmptyResultError) rows = [];
  else throw e;
}

Prevention

When it happens

Trigger: The page script returned null/undefined or an empty array — TikTok's recommend-user API returned zero suggestions or the request path silently degraded.

Common situations: Accounts TikTok has no suggestions for; TikTok experiments returning empty recommendation payloads; a bug/regression where the script returns a non-array.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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