Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Record Performance Traces with Puppeteer

Use Puppeteer’s tracing API to capture a bounded page navigation or interaction, save the trace or handle its returned buffer, and inspect the result in a timeline viewer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Puppeteer’s page.tracing.start() and page.tracing.stop() around the page activity you want to investigate. Set a path to save the trace as a file, then open it in Chrome DevTools or a timeline viewer. A trace captures performance data for diagnosis; it is not a video recording and does not identify or fix a problem automatically.

Record a trace to a file

Install Puppeteer in a Node.js project, then start tracing immediately before the navigation or interaction you want to examine and stop tracing when that activity is complete:

As an Amazon Associate I earn from qualifying purchases.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();

    await page.tracing.start({ path: 'trace.json' });
    await page.goto('https://www.example.com');
    await page.tracing.stop();
  } finally {
    await browser.close();
  }
})();

Replace the example URL with the page you want to inspect. The trace is written to trace.json. Keep the interval between start() and stop() limited to the navigation or interaction you need: tracing records the activity in that window, and only one trace can be active per browser.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture a user interaction instead of navigation

Start tracing before performing the relevant interaction, such as clicking a button, and stop after the page has finished the work you want to inspect. For example:

await page.goto('https://www.example.com');
await page.tracing.start({ path: 'interaction-trace.json' });
await page.click('button');
await page.tracing.stop();

Choose the interaction and stop point deliberately. A trace is useful for examining recorded browser activity, but collecting one does not itself explain the cause of a slowdown.

Return trace data without writing a file

If you omit path, Puppeteer does not write the trace to disk. The stop method can return the trace data as a Uint8Array, which your script can handle or save itself:

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
const trace = await page.tracing.stop();
if (trace) {
  require('node:fs').writeFileSync('trace.json', trace);
}

The API type describes stop() as returning Promise<Uint8Array | undefined>. Check that a buffer was returned before using it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure categories, screenshots, and buffer size

page.tracing.start() accepts a tracing options object. The documented options include:

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
  • path: output file path. If omitted, use the buffer returned by stop() if you need to retain the trace.
  • categories: tracing categories to include or exclude. Prefix a category with - to exclude it.
  • screenshots: whether to capture screenshots alongside tracing data. The documented default is false.
  • bufferSize: trace buffer size in kilobytes. The reference states that Chromium uses a 200 MB (200,000 KB) default when this option is unspecified or set to zero.

For example, set a path and request screenshot capture with:

await page.tracing.start({
  path: 'trace.json',
  screenshots: true
});

Use only the categories and options relevant to the question you are investigating. Consult the TracingOptions reference for the installed Puppeteer version before relying on a particular category or default.

Open and interpret the trace

After stopping the trace, open the output in Chrome DevTools or a timeline viewer. Use the timeline to inspect what happened during the bounded period you recorded. The trace is diagnostic evidence: you still need to interpret the recorded activity and investigate the underlying issue.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Performance, reliability, and setup considerations

  • Keep trace windows bounded. Start just before the activity of interest and stop when it is done. This avoids collecting unrelated activity and respects the one-active-trace-per-browser limit.
  • Choose output handling intentionally. A path writes trace data to disk; without a path, handle the returned buffer if you need to keep or transfer the trace.
  • Use the right package for browser setup. Puppeteer’s installation documentation says npm i puppeteer downloads a compatible Chrome during installation. npm i puppeteer-core installs the library without downloading Chrome, so use it when you are managing the browser separately.
  • Check version-specific docs. Puppeteer’s official reference pages surfaced here show versions 25.3.0, 25.9.0, and 25.12.0 on different pages. The API concepts are documented, but verify the reference matching your installed version before depending on a signature or default.

Troubleshooting

No trace file appears

Confirm that path was supplied to page.tracing.start() and that page.tracing.stop() completed. If you omit the path, Puppeteer does not write a file; use the returned buffer instead.

The trace contains too much unrelated activity

Move start() closer to the navigation or interaction you want to study and call stop() promptly after it. Trace only one bounded activity at a time.

You expected screenshots in the trace

Set screenshots: true in the tracing options. Screenshot capture is documented as off by default.

You need a video rather than performance data

page.tracing produces trace data for performance inspection. Puppeteer’s separate page.record() API is experimental and uses Chrome’s Page.startScreenRecording API to output an MP4 video stream; it is not a substitute for a performance trace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a clean screenshot rather than a performance trace, ScreenshotNeo returns an image or PDF from one request. It does not replace Puppeteer tracing or produce a performance trace.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Before a screenshot, it accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.

Sign up for 1,000 free screenshots a month, with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.