apify/crawlee · error · Error
Function `startTracing()` is not available in incognito mode
Error message
Function `startTracing()` is not available in incognito mode
What it means
Playwright's tracing API lives on the Browser, not on a BrowserContext, so in incognito mode (where the wrapper only exposes an incognito context) startTracing() cannot be supported and always throws. Use context-level tracing via Playwright's tracing module on the underlying context if tracing is needed.
Source
Thrown at packages/browser-pool/src/playwright/playwright-browser.ts:74
browserType(): BrowserType {
return this.#browserType!;
}
async newPage(...args: Parameters<BrowserContext['newPage']>): ReturnType<BrowserContext['newPage']> {
return this.#browserContext.newPage(...args);
}
async newContext(): Promise<never> {
throw new Error('Function `newContext()` is not available in incognito mode');
}
async newBrowserCDPSession(): Promise<never> {
throw new Error('Function `newBrowserCDPSession()` is not available in incognito mode');
}
async startTracing(): Promise<never> {
throw new Error('Function `startTracing()` is not available in incognito mode');
}
async stopTracing(): Promise<never> {
throw new Error('Function `stopTracing()` is not available in incognito mode');
}
}
View on GitHub (pinned to dbe57fb09c)
Solutions
- Use the underlying context's tracing (context.tracing.start()) from the Playwright BrowserContext instead of browser-level startTracing().
- Disable tracing calls when useIncognitoPages is true, or run tracing in a separate non-incognito browser instance.
- Toggle useIncognitoPages: false if browser-level tracing is essential to your workflow.
Example fix
// before
await browserController.startTracing({ path: 'trace.zip' });
// after
await page.context().tracing.start({ screenshots: true });
// ... work ...
await page.context().tracing.stop({ path: 'trace.zip' }); Defensive patterns
Strategy: validation
Validate before calling
if (!launchContext.useIncognitoPages) {
await browserController.startTracing({ path: 'trace.zip' });
} Type guard
function supportsBrowserTracing(useIncognitoPages: boolean): boolean {
return !useIncognitoPages;
} Try / catch
try {
await browserController.startTracing(opts);
} catch (err) {
if (err instanceof Error && err.message.includes('startTracing')) {
await page.context().tracing.start(opts); // context-level tracing fallback
} throw err;
} Prevention
- Prefer context.tracing.start()/stop() which works in both modes.
- Wrap tracing start/stop in a helper that checks the incognito flag.
- Don't copy tracing code from non-incognito examples without checking the mode.
When it happens
Trigger: Calling browserController.startTracing() when the Playwright plugin was created with useIncognitoPages: true.
Common situations: Recording performance/trace files for debugging or CI artifacts while running with incognito pages; generic browser automation code that unconditionally starts tracing.
Related errors
- Function `stopTracing()` is not available in incognito mode
- Function `newContext()` is not available in incognito mode
- Function `newBrowserCDPSession()` is not available in incogn
- A new page can be created with provided context only when us
- A new page can be created with provided context only when us
AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30).
Data as JSON: /api/errors/f3d978c38f87e5c2.
Report an issue: GitHub.