jackwener/OpenCLI · warning · EmptyResultError
TikTok returned no notifications
Error message
TikTok returned no notifications
What it means
This library's TikTok notifications command collects rows from a scraped page and throws EmptyResultError when the result is not a non-empty array. It exists so an empty/blocked fetch is reported explicitly instead of silently returning zero results. The companion failureMessage 'Failed to load TikTok notifications' and emptyPattern 'No notifications returned' are surfaced to the CLI user.
Source
Thrown at clis/tiktok/notifications.js:123
}
async function listNotifications(page, args) {
const limit = requireLimit(args.limit, { fallback: DEFAULT_LIMIT, max: MAX_LIMIT });
const typeKey = requireNotificationType(args.type);
await page.goto('https://www.tiktok.com/foryou', { waitUntil: 'load', settleMs: 5000 });
let rows;
try {
rows = await page.evaluate(buildNotificationsScript(limit, typeKey));
} catch (error) {
throwTikTokPageContextError(error, {
authMessage: 'TikTok requires login to read notifications',
emptyPattern: /No notifications returned/,
emptyTarget: 'tiktok notifications',
failureMessage: 'Failed to load TikTok notifications',
});
}
if (!Array.isArray(rows) || rows.length === 0) {
throw new EmptyResultError('tiktok notifications', 'TikTok returned no notifications');
}
return rows;
}
export const notificationsCommand = cli({
site: 'tiktok',
name: 'notifications',
access: 'read',
description: 'Read TikTok inbox notifications (likes, comments, mentions, followers) via page-context APIs',
domain: 'www.tiktok.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of notifications (max ${MAX_LIMIT})` },
{
name: 'type',
default: 'all',
help: 'Notification type',View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the automation browser has an authenticated TikTok session (cookies present) before calling listNotifications
- Re-run the command; transient blocks often resolve on retry after a delay
- Check the returned page manually (save HTML/screenshot) to confirm whether TikTok changed the notifications markup
- Upgrade the library in case selectors were updated for a newer TikTok page
Example fix
// before
const rows = await listNotifications();
console.log(rows.length);
// after
let rows;
try {
rows = await listNotifications();
} catch (e) {
if (e.name === 'EmptyResultError') rows = [];
else throw e;
}
console.log(rows.length); Defensive patterns
Strategy: try-catch
Validate before calling
const session = await browser.cookies.get('tiktok.com', 'sessionid');
if (!session) throw new Error('Not logged into TikTok: notifications require an authenticated session'); Type guard
function hasRows(v) {
return Array.isArray(v) && v.length > 0;
} Try / catch
let rows = [];
try {
rows = await listNotifications();
} catch (e) {
if (e.name === 'EmptyResultError' || /no notifications/i.test(e.message)) {
console.warn('No TikTok notifications available (check login/session)');
} else {
throw e;
}
} Prevention
- Persist a logged-in TikTok session in the automation browser before calling notification commands
- Check sessionid cookie presence as a precondition
- Treat empty results as data, not crashes: catch EmptyResultError and default to []
- Cache the last good result to distinguish 'truly empty' from 'blocked'
When it happens
Trigger: listNotifications finished its scrape but `rows` is undefined, not an array, or an empty array — e.g. TikTok returned a page without notification markup, the session cookie is absent/expired, or a login/bot-wall page replaced the notifications DOM.
Common situations: Running without being logged into TikTok in the automation browser; TikTok A/B-changing the notifications page; rate-limiting returning a stub page; network hiccup yielding an empty payload.
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
- No chats visible in sidebar. Are you logged in?
- No creator videos were returned. Confirm the current Chrome
- No videos found on /explore + suffix
- TikTok returned an empty recommend feed
- BUTTON_NOT_FOUND: Follow button not on profile page (logged
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d1c64a301caf86f9.
Report an issue: GitHub.