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

Use a Chromium CDP session, enable the Network domain, and listen for Network.requestWillBeSent. Each event includes an initiator object that explains whether the browser started the request from HTML parsing, a script, a preload, a redirect-related condition, or another browser mechanism. Enable the Debugger domain before navigation when you need a JavaScript call stack. Store every event observation keyed by request ID, including redirects, frame IDs, timestamps, and the raw initiator object.

This method gives Chromium-level causality. Playwright’s regular Request API remains useful for portable lifecycle, frame, and redirect information, but it does not replace the CDP initiator stack.

What you will capture

The Network.requestWillBeSent event is emitted when Chromium is about to send a request. Its payload normally contains:

  • requestId, method, URL, headers and post data (when exposed by the protocol).
  • type, the resource type such as Document, Script, Fetch or Image.
  • frameId and loaderId, which identify the browsing context and load.
  • A protocol timestamp.
  • initiator, with a type and optional URL, source location, request ID and stack.
  • redirectResponse when this observation follows a server redirect.

Keep the raw event. Fields can be absent for legitimate reasons, and converting every cause into a made-up JavaScript stack loses useful evidence.

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.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Prerequisites and Chromium scope

  • Install Playwright and a Chromium browser: npm install playwright, followed by npx playwright install chromium if the browser is not already installed.
  • Run the collector against Chromium. Playwright limits CDPSession to Chromium-based browsers; the reviewed API documentation does not establish the same workflow for Firefox or WebKit.
  • Create the CDP session and register listeners before the navigation or page action whose requests you need.

Playwright describes a CDP session as a way to “talk raw Chrome Devtools Protocol.” See the CDPSession API and BrowserContext API for the session-creation methods.

Complete JavaScript collector

The following script records observations, retains redirect data, and writes a JSON file after the page has settled. It is illustrative code based on the documented API and protocol fields; adapt the wait condition to the site you are diagnosing.

const { chromium } = require('playwright');
const fs = require('node:fs/promises');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext();
  const page = await context.newPage();
  const cdp = await context.newCDPSession(page);

  // Enable both domains before navigation.
  await cdp.send('Network.enable');
  await cdp.send('Debugger.enable'); // required for script initiator stacks

  const observations = new Map();
  cdp.on('Network.requestWillBeSent', event => {
    const row = {
      requestId: event.requestId,
      url: event.request.url,
      method: event.request.method,
      resourceType: event.type,
      frameId: event.frameId ?? null,
      loaderId: event.loaderId ?? null,
      timestamp: event.timestamp,
      initiator: event.initiator ?? null,
      redirectResponse: event.redirectResponse ?? null
    };

    // A request ID can reappear around redirects. Preserve the sequence.
    const list = observations.get(event.requestId) ?? [];
    list.push(row);
    observations.set(event.requestId, list);
  });

  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.waitForTimeout(500); // optional window for late requests

  const output = Object.fromEntries(observations);
  await fs.writeFile('request-initiators.json', JSON.stringify(output, null, 2));
  await browser.close();
})();

Run it with node collect-initiators.js. The resulting JSON is grouped by protocol request ID, but each value is an array because one ID should not be assumed to represent one independent HTTP hop.

How to read the initiator object

Parser initiators

A parser initiator generally points to a document URL and source line or column. This indicates that HTML parsing encountered a resource reference such as a script, stylesheet, image, iframe, or preload. It is a source location in the parsed document, not a JavaScript call stack.

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

Script initiators

A script initiator can include a URL, line and column, and a stack. The stack may contain call frames and parent asynchronous stack information. The Debugger domain must be enabled before collection for this detail to be available. A missing stack does not prove that no script caused the request: browser behavior and the request’s cause determine which fields are populated.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Other protocol types

The current Network schema includes parser, script, preload, SignedExchange, preflight, FedCM and other initiator types. Record the type exactly. A preflight, browser-managed authentication step or other non-script cause should not be presented as a fabricated application call chain.

Request and frame identifiers

requestId lets you correlate related protocol events. frameId tells you which frame owns the load, while the initiator describes why Chromium started it. Ownership and causality are different questions; an iframe can own a request that was triggered by markup or script in that frame.

Redirects require a separate relationship

When a response redirects, the next requestWillBeSent observation can contain redirectResponse. Keep that response alongside the new observation instead of overwriting the earlier row. A redirect is an HTTP relationship, not a JavaScript initiator stack.

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

Playwright also exposes Request.redirectedFrom() and Request.redirectedTo(), which connect separate Request objects across server redirects. Use those methods as a complementary, higher-level view; do not label the redirect chain as the script that initiated the original request.

Attach to the right target and page

Create the session from the page’s browser context:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
const cdp = await page.context().newCDPSession(page);

browserContext.newCDPSession(pageOrFrame) accepts a Page or Frame target. If you need a child frame’s own protocol target, attach to that target deliberately and document which target produced the events. A single page session will not magically recover events emitted before it was created.

Event ordering and data retention

For richer network diagnostics you may also listen for Network.requestWillBeSentExtraInfo. The protocol does not guarantee whether that event arrives before or after requestWillBeSent, and ExtraInfo can be missing. Correlate both by request ID and tolerate either order.

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

For production collectors, store an append-only event sequence or an array per request ID. Include raw protocol objects, null or missing values, and timestamps. A one-row map that blindly replaces the previous value can erase redirect observations and make later analysis misleading.

CDP versus Playwright’s Request API

Need Best layer Important boundary
Initiator type, source location and Chromium script stack CDP Network events Chromium-only; enable Debugger for script stacks.
Portable request lifecycle events Playwright Request events Does not replace the CDP initiator object or stack.
Which frame issued a request Request.frame() Can throw for service-worker requests and navigation requests made before a corresponding frame exists.
Service-worker ownership Request.serviceWorker() Chromium-only.
Server redirect chain redirectedFrom()/redirectedTo() or CDP redirectResponse Redirect causality is not a JavaScript initiator stack.

Choose CDP when the output must explain Chromium’s initiator metadata. Choose Playwright’s abstraction when cross-browser request observation is more important than protocol-level stack detail.

Common failure modes and fixes

No requests appear

Cause: the listener was registered after navigation, or Network.enable was never sent. Fix: create the session, enable Network, attach the handler, then call goto or perform the action.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The initiator has no stack

Cause: Debugger was not enabled early enough, or the cause is not a script. Fix: send Debugger.enable before the request and branch on initiator.type; accept that parser and browser-managed causes do not have JavaScript stacks.

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

Only the final URL is visible after a redirect

Cause: the collector overwrote a request ID’s previous observation. Fix: append each event to an array and preserve redirectResponse. For Playwright-level navigation, inspect redirectedFrom() and redirectedTo().

Request.frame() throws

Cause: the request came from a service worker or occurred before its frame existed. Fix: catch that case, use the CDP frameId when present, and retain the request as frame-unknown when it is not.

ExtraInfo cannot be joined

Cause: event order is nondeterministic or ExtraInfo was not emitted. Fix: maintain a map keyed by request ID and merge whichever event arrives first; treat the second as optional.

Different browsers produce different output

Cause: this is a Chromium CDP workflow, not a cross-browser guarantee. Fix: scope the collector and its assertions to Chromium, or fall back to Playwright Request events for portable diagnostics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance and reliability practices

  • Filter or serialize incrementally for pages with many requests; retaining raw events is more reliable than retaining only a derived stack.
  • Use a bounded post-action wait when you need late analytics requests, but avoid an unbounded “network idle” assumption on pages with long polling.
  • Keep timestamps and frame IDs so later analysis can distinguish concurrent requests from sequential redirects.
  • Do not infer a unique HTTP transaction from a request ID. Preserve every observation associated with that ID.
  • Close the browser in a finally block in long-running tooling so a failed navigation does not leak Chromium processes.

Or skip the browser setup

If your actual goal is a clean visual capture rather than network-causality debugging, ScreenshotNeo provides a single screenshot API request. Its cleanup steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.

Use the documented endpoint and options at ScreenshotNeo documentation:

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

Equivalent Python:

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)

Equivalent Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also exposes an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Start at the free ScreenshotNeo sign-up.

When this approach is the right one

Use the CDP collector when you need to explain why Chromium initiated a request, locate a triggering script, distinguish parser activity from browser-managed traffic, or preserve redirect evidence. Use ordinary Playwright Request events when portability and a simpler lifecycle model matter more than Chromium’s initiator stack.

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

Frequently Asked Questions

Can I obtain the same initiator stack in Firefox or WebKit?

The documented workflow is based on Chromium CDP sessions. The available Playwright documentation does not establish an equivalent initiator-stack workflow for Firefox or WebKit.

Does a redirect tell me which JavaScript function made the request?

No. Redirect data describes an HTTP response and the subsequent request. A JavaScript initiator stack, when available, is a separate protocol field.

What should I store when a protocol field is missing?

Keep the field null or absent in the raw observation. Missing metadata is valid protocol output and should not be replaced with an inferred value.

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.

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