How to Get Recent Browser Process Logs in Puppeteer
Get buffered browser output with @puppeteer/browsers, or forward it from Puppeteer with dumpio. Learn which method fits and how to troubleshoot missing logs.
To retrieve buffered recent browser output, use getRecentLogs() on the Process wrapper from @puppeteer/browsers. If you launch Chrome with the usual puppeteer.launch() API, set dumpio: true to forward the browser process’s stdout and stderr to Node’s output streams. These are different APIs: puppeteer.launch() does not return the Process wrapper or provide its recent-log accessor.
Choose the log source that matches your setup
| Need | Use | What you get |
|---|---|---|
| Read recent output from a browser process wrapper | @puppeteer/browsers Process.getRecentLogs() |
An array of buffered stdout and stderr lines |
| See browser output as Puppeteer runs | puppeteer.launch({dumpio: true}) |
Browser output forwarded to Node’s stdout and stderr |
| Inspect Puppeteer protocol activity | NODE_DEBUG="puppeteer:*" |
Internal protocol diagnostics, not browser process output |
Get buffered recent logs with @puppeteer/browsers
The Process API documents getRecentLogs(): string[] as returning recent browser logs combined from stderr and stdout. Use this when your code launches a browser through @puppeteer/browsers and needs to inspect its captured output on demand. See the browser management documentation and the Process implementation.
import {launch} from '@puppeteer/browsers';
const process = launch({
executablePath: '/path/to/chrome',
});
try {
// Run work that uses the browser process here.
} finally {
// Call this when you need diagnostic output, such as after a failure.
console.error(process.getRecentLogs().join('\n'));
await process.close();
}
Replace /path/to/chrome with the executable path for your environment. Use the launch options and lifecycle methods supported by the version of @puppeteer/browsers installed in your project; this package’s Process is distinct from the Browser returned by puppeteer.launch().
The reviewed source implementation reads both streams line by line, ignores blank lines, and keeps a bounded buffer. It currently retains up to 1,000 nonblank lines, but that is an implementation detail, not a documented compatibility guarantee. Do not build application logic around that exact capacity.
Forward browser output with Puppeteer launch()
For regular Puppeteer launches, enable dumpio. It forwards browser process stdout and stderr to the corresponding Node.js output streams; it is false by default. This is the documented approach to see browser output during a launch failure or crash. See the LaunchOptions reference and Puppeteer debugging guide.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({
dumpio: true,
});
try {
const page = await browser.newPage();
await page.goto('https://example.com');
} finally {
await browser.close();
}
Save the output through your existing Node process manager, container logging, or application logging setup if you need persistent logs. dumpio forwards output; it does not give you a recent-lines array. If you need that exact accessor, use the Process API above and confirm your installed package exposes it.
Run protocol and browser-management diagnostics separately
Use NODE_DEBUG="puppeteer:*" to inspect Puppeteer’s internal protocol diagnostics. This is not a substitute for browser stdout and stderr, and the debugging guide warns that protocol logs may contain sensitive information. Review logs before storing or sharing them.
# Linux or macOS
NODE_DEBUG="puppeteer:*" node app.js
# Windows PowerShell
$env:NODE_DEBUG="puppeteer:*"; node app.js
For verbose operations in the separate @puppeteer/browsers package, use NODE_DEBUG="puppeteer:browsers:*". Choose the namespace that matches the layer you are diagnosing. See the browser management documentation.
Troubleshoot missing or unhelpful logs
| Symptom | Likely cause | What to do |
|---|---|---|
getRecentLogs is not available |
The object is a Puppeteer Browser, or the installed package version does not expose the API you expected. |
Check the import, object type, and installed @puppeteer/browsers version. The accessor belongs to its Process API. |
| No browser output appears in the Node terminal | dumpio is unset or false, or the environment captures Node output elsewhere. |
Set dumpio: true, then inspect the stdout and stderr destinations configured by your process manager or runtime. |
| Logs disappear after the process exits | Forwarding alone does not persist output. | Redirect or collect Node stdout and stderr using your normal runtime logging setup. For buffered retrieval, use getRecentLogs() before closing the process. |
| Protocol debug output does not explain a Chrome crash | NODE_DEBUG="puppeteer:*" shows Puppeteer protocol diagnostics, a different log layer. |
Enable dumpio for browser output, or use the browser process wrapper’s recent logs. |
| Browser fails before expected diagnostics are available | The browser may not have launched, or the environment may be missing dependencies or blocked from downloading a browser. | Check the exact error and environment against the Puppeteer troubleshooting guide. It covers blocked install scripts, Windows extension policy conflicts, and missing system packages in Google Cloud Run’s default Node.js runtime. |
Logs help identify the failing layer; they do not establish the fix by themselves. Check the error, operating system, runtime, and Puppeteer version together.
Performance, reliability, and cost
- Performance:
dumpioforwards output as it is emitted, which is useful during diagnosis. Verbose protocol logging can produce substantial output, so enable it for the debugging window you need. - Reliability: A bounded recent-log buffer can omit older output, and its capacity may change between package versions. Persistent capture depends on your Node process’s logging destination.
- Cost: These logging options do not set a price. Runtime, storage, and log-ingestion costs depend on your hosting and logging services; check their configuration and pricing separately.
- Sensitive data: Protocol diagnostics may include sensitive information. Review and restrict access to collected logs.
Or skip the browser setup
If your goal is to capture a page rather than debug Puppeteer itself, ScreenshotNeo is a website screenshot API and MCP server. A single GET request returns an image or PDF; its API documentation lists the available options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer())));
Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and capture your first 1,000 screenshots without a card.
FAQ
Does Puppeteer have a getRecentLogs() method?
The documented accessor is on the Process class from @puppeteer/browsers, not the usual Browser object returned by puppeteer.launch().
Does dumpio keep a copy of recent output?
No. It forwards browser stdout and stderr to Node’s corresponding streams. Store those streams through your runtime logging system if you need a persistent record.
Are browser process logs the same as protocol logs?
No. Browser process logs come from Chrome’s stdout and stderr. NODE_DEBUG="puppeteer:*" emits Puppeteer internal protocol diagnostics.


