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

  1. Use the underlying context's tracing (context.tracing.start()) from the Playwright BrowserContext instead of browser-level startTracing().
  2. Disable tracing calls when useIncognitoPages is true, or run tracing in a separate non-incognito browser instance.
  3. 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

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


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/f3d978c38f87e5c2. Report an issue: GitHub.