To detect that the whole Pyppeteer browser connection has ended, listen for Browser.Events.Disconnected. For a quick, point-in-time check of a browser process that Pyppeteer launched, inspect browser.process.poll(). Use page.isClosed() only to check whether one page has closed; it does not tell you whether the browser as a whole is gone.
Choose the check that matches what you mean by “closed”
Pyppeteer exposes three useful signals, but they describe different things. A browser can have several pages, so a closed tab and a disconnected browser are not interchangeable states.
| What you need to know | Check | What it tells you |
|---|---|---|
| Did a particular page close? | page.isClosed() |
Whether that page has closed. |
| Did the browser connection end? | Browser.Events.Disconnected |
An event-driven notification that Pyppeteer’s connection to the browser ended. |
| Is a locally launched browser process still running? | browser.process.poll() |
A point-in-time process check: None means the process has not exited; a return code means it has exited. |
For most asynchronous applications, register the browser’s disconnected event as soon as you launch or connect. Use the process check as an additional diagnostic only when Pyppeteer launched the browser locally.
Listen for the browser’s disconnected event
The browser API exposes Browser.Events.Disconnected. Register a handler immediately after obtaining the browser object so your application can react if the DevTools connection ends while work is underway.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from pyppeteer import launch
from pyppeteer.browser import Browser
async def main():
browser = await launch()
browser.on(
Browser.Events.Disconnected,
lambda: print("Pyppeteer browser disconnected")
)
# Do browser work here.
await browser.close()
The handler is asynchronous in effect: it runs when the disconnect occurs, rather than waiting for your code to ask whether the browser is still connected. Closing the browser yourself also ends the connection, so the event can occur during intentional cleanup as well as after an unexpected exit. If your program must distinguish those cases, record that it is shutting down before calling close().
Use an event to coordinate cleanup
A print statement is useful for a small script, but a service usually needs to signal other tasks. A standard asyncio.Event gives the callback a simple way to notify the rest of the program:
import asyncio
from pyppeteer import launch
from pyppeteer.browser import Browser
async def main():
browser = await launch()
disconnected = asyncio.Event()
browser.on(Browser.Events.Disconnected, disconnected.set)
page = await browser.newPage()
try:
await page.goto("https://example.com", waitUntil="domcontentloaded")
# Continue the work that depends on this browser session.
finally:
# If this program owns the launched browser, close it during cleanup.
await browser.close()
if disconnected.is_set():
print("The browser connection has ended")
asyncio.run(main())
In a long-running worker, other tasks can wait on disconnected.wait() and begin shared cleanup when it completes. Keep that cleanup idempotent: several in-flight operations may notice a failure at nearly the same time. Also distinguish expected shutdown from an unexpected disconnect if your application logs, retries, or alerts on browser loss.
Check a launched browser process directly
When Pyppeteer launches Chromium, browser.process refers to the associated subprocess. Its poll() method checks whether that process has exited without blocking for it to finish:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
proc = browser.process
browser_is_running = proc is not None and proc.poll() is None
if not browser_is_running:
print("The locally launched browser process is not running")
This is a snapshot, not a subscription. The process can exit immediately after a successful poll, so use the disconnect event when you need to react to a change over time. Conversely, an event handler tells you the connection ended; the process check tells you whether a particular local process is still alive.
When browser.process is None
A browser obtained with connect() is not a process Pyppeteer launched. In that case, browser.process is None, so there is no local subprocess to poll. Do not treat None alone as proof that the remote browser is closed; use the browser’s disconnected event for the connection state.
Use page.isClosed() only for tab state
Call page.isClosed() when the question is whether a specific page is still open:
if page.isClosed():
print("This page has closed")
It reports the state of that page, not every page in the browser and not the browser connection itself. A browser may still be connected while one page has closed; it may also become disconnected while your code still holds a page object. If your task depends on both states, check the page and listen for the browser event rather than using one as a substitute for the other.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Handle disconnects during page operations
A browser can disappear between a state check and the next command. That is why checking first and then assuming every later operation will succeed is unsafe: a page call made after the browser connection has ended can raise a protocol or connection error. Put error handling around the operation that can fail, and let one shared lifecycle path decide whether to discard the session, clean up, or retry.
async def capture_page(page, disconnected):
try:
await page.goto("https://example.com", waitUntil="domcontentloaded")
return await page.title()
except Exception:
# The operation failed. Do not continue using this session blindly.
if disconnected.is_set():
print("Browser disconnected during the operation")
raise
This example re-raises the exception so the caller can apply its own retry or failure policy. Catching every exception and treating it as a disconnect would hide unrelated errors, such as an invalid operation or a page-specific failure. Conversely, a connection can fail just before the event callback runs, so an unset event at the instant of the exception does not prove the session is healthy. Treat a protocol or connection failure as a reason to stop issuing work on that session until its state is resolved.
Retry with a new session, not a stale page
- Decide which failures are retryable for your workload; do not retry every page error automatically.
- After a browser-wide disconnect, discard the old browser and page objects for new work.
- If your program launched the browser, close it during cleanup when it is still available, then launch a replacement according to your service’s retry limits.
- If your program only connected to a browser owned elsewhere, disconnecting your client does not mean you should terminate that shared browser.
Close the browser or disconnect the client?
Use the cleanup method that matches ownership. Pyppeteer documents close() as closing connections and terminating the browser process. Use it when your code launched and owns that process. Use disconnect() when you only need to drop the Pyppeteer client connection; it does not mean your client should shut down a browser owned by another component.
# Your code launched and owns this browser:
await browser.close()
# Your code connected to a browser owned elsewhere:
await browser.disconnect()
Do not call either method merely to test whether a browser is closed: both change the connection state. Observe the event or, for a locally launched process, poll its subprocess instead.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Troubleshooting common checks
page.isClosed() is false, but a browser command fails
The page-level result is not a guarantee that the browser connection will remain usable. The connection may have ended after the check, or the failure may have another cause. Check the disconnected signal, stop using the session after a connection or protocol error, and let the caller decide whether to replace it.
browser.process is None
This is expected for a browser reached through connect(). It means Pyppeteer has no locally launched process object to poll. Monitor the connection with Browser.Events.Disconnected.
The disconnect handler did not log anything
Confirm the handler was registered on the browser object returned by launch() or connect(), and do so before the work whose disconnect you need to observe. If the connection was already gone before registration, the event is not a substitute for a retrospective process check. For a locally launched browser, inspect browser.process.poll() as a point-in-time check.
The event fires during normal shutdown
That can happen because close() ends the browser connection too. Set an application-owned shutdown flag before intentional cleanup, then interpret the event using that flag rather than treating every disconnect as a crash.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Behavior differs across installations
Pyppeteer is an unofficial Python port of Puppeteer, and its GitHub repository describes the project as unmaintained. Pin the dependency used in production and verify the API behavior against that exact installed version or fork, especially before relying on lifecycle handling for recovery.
Performance, reliability, and cost considerations
The process check is a point-in-time poll; it is not a reason to poll in a tight loop. Registering one event callback lets the application respond to a disconnect without repeatedly asking for status. Neither method prevents a browser from exiting during an operation, so retain exception handling around work that uses the connection.
The relevant cost in application terms is operational: a retry can repeat work, and a stale session can waste worker time if it is reused after a failure. Keep retry limits and cleanup ownership explicit. The API behavior described here does not establish a universal performance figure or a particular Pyppeteer charge; measure resource use and retry behavior in your own deployment.
Or skip the browser setup
If your goal is to get a website screenshot rather than automate a browser session, ScreenshotNeo provides a screenshot API and MCP server. This one GET request saves an image response:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQuick Recap
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. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server offers screenshot tools for AI agents, and the Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000. 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.

