jackwener/OpenCLI · error · Error

No friend suggestions returned by TikTok + suffix

Error message

No friend suggestions returned by TikTok + suffix

What it means

The friends command pages TikTok's recommend-user API for friend suggestions; if no unique suggestion rows are collected, it throws 'No friend suggestions returned by TikTok'. When a page fetch failed, the API error is appended as '(recommend-user API failed: ...)' so callers can see why suggestions were empty.

Source

Thrown at clis/tiktok/friends.js:100

          const row = normalizeUserRow(entry?.user || entry, dedup.size + 1);
          if (row && !dedup.has(row.username)) dedup.set(row.username, row);
        }
        if (data.hasMore !== true) break;
        cursor = asNumber(data.cursor) ?? cursor + list.length;
      } catch (error) {
        apiFailure = error instanceof Error ? error.message : String(error);
        break;
      }
    }
  }

  const rows = Array.from(dedup.values())
    .slice(0, limit)
    .map((row, index) => ({ ...row, index: index + 1 }));

  if (rows.length === 0) {
    const suffix = apiFailure ? ' (recommend-user API failed: ' + apiFailure + ')' : '';
    throw new Error('No friend suggestions returned by TikTok' + suffix);
  }
  return rows;
})()
`;
}

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',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the '(recommend-user API failed: ...)' suffix for the root API error and fix that first.
  2. Refresh cookies/msToken by logging in normally and retrying.
  3. Retry after a delay — recommendation endpoints are rate-limited and often recover.
  4. Confirm in a browser that tiktok.com shows friend suggestions for this account.
  5. If the account has no suggestions, catch this error and treat it as an empty list.
Defensive patterns

Strategy: try-catch

Type guard

function isFriendsEmpty(e) {
  return e instanceof Error && e.message.startsWith('No friend suggestions returned by TikTok');
}
function hadApiFailure(e) { return /recommend-user API failed:/.test(e?.message || ''); }

Try / catch

try {
  rows = await friendsCommand({ limit });
} catch (e) {
  if (isFriendsEmpty(e)) {
    if (hadApiFailure(e)) await sleep(60_000); // retry after API failure
    else rows = []; // no suggestions for this account
  } else throw e;
}

Prevention

When it happens

Trigger: The recommend-user endpoint returned an empty list (no suggestions generated for the account); the first API call failed (assertTikTokApiSuccess threw) setting apiFailure; msToken/signature issues causing rejected requests.

Common situations: Fresh or low-activity accounts with no friend suggestions; TikTok rate-limiting the recommend endpoint from automation; logged-out or semi-logged-in state producing empty recommendation payloads.

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/bb5454644f6f41c0. Report an issue: GitHub.