{"record":{"id":"96c8db44050cef46","repo":"microsoft/playwright","slug":"tracing-is-not-started","errorCode":null,"errorMessage":"Tracing is not started","messagePattern":"Tracing is not started","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/backend/tracing.ts","lineNumber":67,"sourceCode":"});\n\nconst tracingStop = defineTool({\n  capability: 'devtools',\n\n  schema: {\n    name: 'browser_stop_tracing',\n    title: 'Stop tracing',\n    description: 'Stop trace recording',\n    inputSchema: z.object({}),\n    type: 'readOnly',\n  },\n\n  handle: async (context, params, response) => {\n    const browserContext = await context.ensureBrowserContext();\n    // eslint-disable-next-line no-restricted-syntax\n    const traceLegend = (browserContext.tracing as any)[traceLegendSymbol];\n    if (!traceLegend)\n      throw new Error('Tracing is not started');\n    await browserContext.tracing.stop();\n    // eslint-disable-next-line no-restricted-syntax\n    delete (browserContext.tracing as any)[traceLegendSymbol];\n\n    response.addTextResult(`Trace recording stopped.`);\n    response.addFileLink('Trace', `${traceLegend.tracesDir}/${traceLegend.name}.trace`);\n    response.addFileLink('Network log', `${traceLegend.tracesDir}/${traceLegend.name}.network`);\n    response.addFileLink('Resources', `${traceLegend.tracesDir}/resources`);\n  },\n});\n\nexport default [\n  tracingStart,\n  tracingStop,\n];\n\nconst traceLegendSymbol = Symbol('tracesDir');\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/backend/tracing.ts#L49-L85","documentation":"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).","triggerScenarios":"Calling browser_stop_tracing without a prior successful browser_start_tracing; calling stop twice (the second call finds the symbol already deleted).","commonSituations":"Agent unconditionally stopping tracing in a finally block when start was skipped or failed; retry logic that double-stops.","solutions":["Ensure browser_start_tracing runs successfully before browser_stop_tracing.","Track start/stop state in the caller and skip stop when start did not happen.","Avoid double-stop: clear your 'tracing active' flag immediately after a successful stop."],"exampleFix":"// before\nawait client.callTool('browser_stop_tracing', {}); // throws if never started\n\n// after\nlet tracing = false;\ntry {\n  await client.callTool('browser_start_tracing', {});\n  tracing = true;\n  // ... work ...\n} finally {\n  if (tracing) await client.callTool('browser_stop_tracing', {});\n}","handlingStrategy":"validation","validationCode":"let tracingActive = false;\nasync function safeStartTracing(client) {\n  await client.callTool('browser_start_tracing', {});\n  tracingActive = true;\n}\nasync function safeStopTracing(client) {\n  if (!tracingActive) return;\n  await client.callTool('browser_stop_tracing', {});\n  tracingActive = false;\n}","typeGuard":"function isNotStartedError(e: unknown): boolean {\n  return e instanceof Error && e.message === 'Tracing is not started';\n}","tryCatchPattern":"try {\n  await client.callTool('browser_stop_tracing', {});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Tracing is not started') {\n    // benign: nothing to stop\n  } else throw e;\n}","preventionTips":["Track tracing state in the caller; only stop what you started.","Wrap stop in logic that treats 'not started' as benign."],"tags":["tracing","state-machine","mcp-tool"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}