(Created on )

Puppeteer: Cannot start recording trace while already recording trace.

Tracing is started while another trace is already recording.


Tracing is started while another trace is already recording.

Error message

Cannot start recording trace while already recording trace.

How this error happens

A page cannot start another trace while its current trace is recording.

The snippets use an open Chrome/CDP page named page.

await page.tracing.start();
await page.tracing.start();

How to fix

Start once, run the measured work, and stop once.

await page.tracing.start();

try {
    await page.setContent(
        "<p>Measured work</p>"
    );
} finally {
    const trace = await page.tracing.stop();

    console.log(trace?.byteLength);
}

Things to keep in mind

Run the correction with no active trace. Trace data can contain URLs and page details; avoid publishing it without checking for sensitive information.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →