jackwener/OpenCLI · info · EmptyResultError
document.cookie is empty (Trae uses Electron session cookies
Error message
document.cookie is empty (Trae uses Electron session cookies, mostly httpOnly).
What it means
EmptyResultError from the trae-solo `cookies` command when `document.cookie` evaluates to an empty string. In Electron apps like Trae, most session cookies are set httpOnly and are invisible to document.cookie, so this is an expected limitation rather than a broken page — the library surfaces it explicitly instead of returning an empty table.
Source
Thrown at clis/trae-solo/renderer-storage.js:125
];
},
});
// -------- cookies --------
cli({
site: 'trae-solo',
name: 'cookies',
access: 'read',
description: 'List cookies on the Trae SOLO renderer (JS-visible via document.cookie; httpOnly cookies not shown).',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Index', 'Key', 'Bytes', 'Name', 'Preview', 'Database', 'Version'],
func: async (page) => {
const raw = await page.evaluate('document.cookie');
if (!raw) {
throw new EmptyResultError('trae-solo cookies', 'document.cookie is empty (Trae uses Electron session cookies, mostly httpOnly).');
}
const cookies = raw.split('; ').map((pair) => {
const idx = pair.indexOf('=');
if (idx < 0) return { name: pair, value: '' };
return { name: pair.slice(0, idx), value: pair.slice(idx + 1) };
});
return cookies.map((c, i) => ({
Index: i + 1,
Key: '',
Name: c.name,
Bytes: c.value.length,
Preview: c.value.slice(0, 40) + (c.value.length > 40 ? '…' : ''),
Database: '',
Version: '',
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Use Trae's CDP/DevTools Network.getCookies (via the browser backend) instead of document.cookie to read httpOnly cookies.
- Check DevTools → Application → Cookies to confirm which cookies exist and their flags.
- If you control the app, mark needed cookies non-httpOnly (not recommended for auth cookies).
- Treat the empty result as expected and use another channel (network request capture) for session data.
Example fix
// before
const cookies = await cli('trae-solo', 'cookies'); // EmptyResultError
// after
const cdp = await page.context().newCDPSession(page);
const { cookies } = await cdp.send('Network.getCookies'); // includes httpOnly Defensive patterns
Strategy: try-catch
Type guard
const hasJsCookies = (raw) => typeof raw === 'string' && raw.trim().length > 0;
Try / catch
try {
cookies = await cli('trae-solo', 'cookies');
} catch (e) {
if (/document.cookie is empty/.test(e.message)) {
console.warn('Cookies are httpOnly; use CDP Network.getCookies instead');
cookies = await getCookiesViaCDP(page);
} else throw e;
} Prevention
- Assume Electron session cookies are httpOnly and unreachable from document.cookie.
- Use CDP Network.getAllCookies / DevTools Application panel for cookie inspection.
- Don't build auth flows that depend on reading httpOnly cookies from JS.
- Check cookies exist (non-httpOnly ones) before relying on this command's output.
When it happens
Trigger: Running the cookies command on a Trae renderer whose cookies are all httpOnly or SameSite-protected; a fresh profile with no non-httpOnly cookies set; a page context where no document cookies were written at all.
Common situations: Developers trying to extract auth/session cookies for debugging or API replay — Electron apps typically keep these out of JS reach by design; testing on a brand-new workspace before any cookie-setting request.
Related errors
- antigravity cookies: document.cookie is empty.
- document.cookie is empty (likely all cookies are httpOnly).
- No IndexedDB databases.
- 12306 tk auth cookie missing
- 1point3acres Discuz *_auth cookie missing
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/87f4401924afd061.
Report an issue: GitHub.