microsoft/playwright · error · Error

Tracing is not started

Error message

Tracing is not started

What it means

Thrown by browser_stop_tracing when the tracing legend symbol is absent from browserContext.tracing. The legend is installed by browser_start_tracing and deleted on stop, so its absence means tracing was never started (or has already been stopped).

Source

Thrown at packages/playwright-core/src/tools/backend/tracing.ts:67

});

const tracingStop = defineTool({
  capability: 'devtools',

  schema: {
    name: 'browser_stop_tracing',
    title: 'Stop tracing',
    description: 'Stop trace recording',
    inputSchema: z.object({}),
    type: 'readOnly',
  },

  handle: async (context, params, response) => {
    const browserContext = await context.ensureBrowserContext();
    // eslint-disable-next-line no-restricted-syntax
    const traceLegend = (browserContext.tracing as any)[traceLegendSymbol];
    if (!traceLegend)
      throw new Error('Tracing is not started');
    await browserContext.tracing.stop();
    // eslint-disable-next-line no-restricted-syntax
    delete (browserContext.tracing as any)[traceLegendSymbol];

    response.addTextResult(`Trace recording stopped.`);
    response.addFileLink('Trace', `${traceLegend.tracesDir}/${traceLegend.name}.trace`);
    response.addFileLink('Network log', `${traceLegend.tracesDir}/${traceLegend.name}.network`);
    response.addFileLink('Resources', `${traceLegend.tracesDir}/resources`);
  },
});

export default [
  tracingStart,
  tracingStop,
];

const traceLegendSymbol = Symbol('tracesDir');

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Ensure browser_start_tracing runs successfully before browser_stop_tracing.
  2. Track start/stop state in the caller and skip stop when start did not happen.
  3. Avoid double-stop: clear your 'tracing active' flag immediately after a successful stop.

Example fix

// before
await client.callTool('browser_stop_tracing', {}); // throws if never started

// after
let tracing = false;
try {
  await client.callTool('browser_start_tracing', {});
  tracing = true;
  // ... work ...
} finally {
  if (tracing) await client.callTool('browser_stop_tracing', {});
}
Defensive patterns

Strategy: validation

Validate before calling

let tracingActive = false;
async function safeStartTracing(client) {
  await client.callTool('browser_start_tracing', {});
  tracingActive = true;
}
async function safeStopTracing(client) {
  if (!tracingActive) return;
  await client.callTool('browser_stop_tracing', {});
  tracingActive = false;
}

Type guard

function isNotStartedError(e: unknown): boolean {
  return e instanceof Error && e.message === 'Tracing is not started';
}

Try / catch

try {
  await client.callTool('browser_stop_tracing', {});
} catch (e) {
  if (e instanceof Error && e.message === 'Tracing is not started') {
    // benign: nothing to stop
  } else throw e;
}

Prevention

When it happens

Trigger: Calling browser_stop_tracing without a prior successful browser_start_tracing; calling stop twice (the second call finds the symbol already deleted).

Common situations: Agent unconditionally stopping tracing in a finally block when start was skipped or failed; retry logic that double-stops.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/96c8db44050cef46. Report an issue: GitHub.