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

Puppeteer’s Page events let you observe navigation, network requests, JavaScript diagnostics, dialogs, popups, frames, and workers. Use page.on() for recurring events, page.once() for a one-time wait, and page.off() with the original callback to remove a listener. The key network distinction: a 404 is normally a completed response, not a requestfailed event.

Which Puppeteer page events are available?

The Puppeteer Page API extends EventEmitter. Its event names and callback payloads are documented in the PageEvent enum. The enum reference is on Puppeteer’s /next documentation, so verify event availability against the version installed in your project before depending on an experimental or recently added event.

Category Events What to use them for
Page lifecycle domcontentloaded, load, close Observe document readiness or page closure.
JavaScript diagnostics console, pageerror, error Capture console output, uncaught page exceptions, and page crashes. The console event can include messages for page errors or warnings as well as calls to console methods.
Dialogs and new tabs dialog, popup Handle JavaScript dialogs or access the new Page opened by a page.
Frames frameattached, framenavigated, framedetached Track an iframe’s attachment, navigation, and removal.
Network request, response, requestfinished, requestfailed, requestservedfromcache Observe requests, responses, completion, failures, and cache-served requests.
Workers and diagnostics workercreated, workerdestroyed, metrics, issue Observe worker lifecycle and metrics. issue is listed as experimental in the /next enum; confirm it exists in your installed version before using it.

Callback arguments depend on the event: documented payloads include HTTPRequest, HTTPResponse, Frame, Dialog, ConsoleMessage, and Page. Consult the event reference for the specific event you are handling rather than assuming every event passes the same kind of object.

How do you add and remove listeners?

Attach a listener before the action that might emit the event. This matters when the action can trigger an event immediately, such as clicking a link that opens a popup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.
function logRequest(request) {
  console.log('A request was made:', request.url());
}

page.on('request', logRequest);
page.once('load', () => console.log('Page loaded!'));

// Later, remove the recurring listener with the same function reference.
page.off('request', logRequest);

page.on() keeps listening whenever the event occurs. page.once() removes its listener after the first occurrence. To remove a listener registered with on(), call page.off() with the same event name and function reference; a new, textually identical anonymous function is not the original callback.

How do request, response, completion, and failure differ?

A typical request emits request when it is issued, response when a response arrives, and requestfinished once the response body has downloaded and the request is complete. If a request fails before completion, Puppeteer emits requestfailed instead of requestfinished. A redirect completes the old request and issues another request for the redirected URL. See the HTTPRequest API for the documented lifecycle and failure details.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

A 404 is not usually a request failure

HTTP status codes such as 404 and 503 still represent completed HTTP exchanges. They normally end with requestfinished, not requestfailed. To identify unsuccessful HTTP statuses, inspect the response’s status() instead of treating requestfailed as a general “bad result” event.

Inspecting an actual request failure

For a failed request, HTTPRequest.failure() can return an error string such as net::ERR_FAILED. Puppeteer does not guarantee that failure text will be present, so do not make your error handling depend on a particular string.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.
page.on('requestfailed', request => {
  console.error('Request failed:', request.url(), request.failure());
});

page.on('response', response => {
  if (response.status() >= 400) {
    console.warn('HTTP error status:', response.status(), response.url());
  }
});

How do you handle dialogs, popups, and frames?

Resolve JavaScript dialogs

The dialog event covers JavaScript alert, prompt, confirm, and beforeunload dialogs. Its Dialog payload lets you inspect the type and message, then accept or dismiss the dialog. An unresolved dialog can block page execution, so choose a response in the handler. The Dialog API documents these methods.

page.on('dialog', async dialog => {
  console.log(dialog.type(), dialog.message());
  await dialog.dismiss();
});

Wait for a popup

The popup event supplies a Page for the opened tab or window. Register the one-time listener before clicking or otherwise triggering the popup. The popup remains in the opener’s BrowserContext, as described by the BrowserContext API.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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
const popupPromise = new Promise(resolve => page.once('popup', resolve));
await page.click('a[target="_blank"]');
const popup = await popupPromise;
console.log('Popup URL:', popup.url());

Track iframe changes

The parent Page emits frameattached, framenavigated, and framedetached. Their payload is a Frame, which you can use to inspect the frame tree or interact with the relevant child frame. The Frame API covers frame navigation and hierarchy.

page.on('frameattached', frame => {
  console.log('Frame attached:', frame.url());
});

page.on('framenavigated', frame => {
  console.log('Frame navigated:', frame.url());
});

page.on('framedetached', frame => {
  console.log('Frame detached:', frame.url());
});
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should you use request interception?

Use ordinary request listeners to observe traffic. Do not enable interception solely for logging. When you call page.setRequestInterception(true), every intercepted request stalls until it is continued, answered, or aborted, unless the browser cache completes it. A handler that leaves a request unresolved can hang navigation or resource loading. The setRequestInterception reference explains the behavior and methods.

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.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Interception is appropriate when you need to change, block, or mock traffic. This example aborts PNG requests and continues others:

await page.setRequestInterception(true);
page.on('request', async request => {
  try {
    if (request.url().endsWith('.png')) {
      await request.abort();
    } else {
      await request.continue();
    }
  } catch (error) {
    console.error('Could not resolve intercepted request:', request.url(), error);
  }
});

In production, handle rejected interception promises and account for other interception handlers if using cooperative interception. Every request needs a resolution path.

Or skip the browser setup

If your goal is to capture a website rather than automate browser behavior, ScreenshotNeo is a website screenshot API with a one-request capture. Its API handles cookie banners, popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are not billed. It also has an MCP server so AI agents can take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

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 setup and options, then sign up for 1,000 free screenshots a month with no card.

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

Troubleshooting common event issues

  • The popup listener never fires: Register it before the click or other triggering action, and confirm the site actually opens a new tab or window.
  • A 404 does not trigger requestfailed: That is expected for a completed HTTP exchange. Inspect response.status() for status codes.
  • Navigation hangs after enabling interception: Check every request handler path and ensure each intercepted request is continued, responded to, or aborted. Handle asynchronous failures too.
  • A dialog stops automation: Install a dialog listener and explicitly accept or dismiss the dialog.
  • An event name or behavior is missing: Compare your installed Puppeteer version with the API reference. In particular, the event inventory at /next may describe experimental or newer behavior not present in your version.
  • A listener keeps running after its task: Retain the callback function and remove it using page.off() when finished.

Frequently Asked Questions

Does `page.once()` wait until a page event occurs?

It registers a listener that runs on the next occurrence of the named event, then removes itself. Register it before the action that should trigger the event.

Does `requestfailed` mean the server returned an error status?

No. It signals a request that failed before completion; an HTTP error status such as 404 is normally a completed response.

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.