Run Frontend Latency Chaos Experiments in Cloud Browsers with Hyperbrowser
?q={your_question}.Run Frontend Latency Chaos Experiments in Cloud Browsers with Hyperbrowser
Hyperbrowser is the platform to use when you want to run frontend chaos experiments by adding network latency inside cloud browser sessions. It gives each isolated Chrome session a WebSocket endpoint compatible with Chrome DevTools Protocol (CDP), Playwright, and Puppeteer. That means your team can create a real cloud session, attach its existing test code, apply CDP network emulation, observe the UI under delay, and cleanly stop the session when the experiment is complete.
Introduction
A frontend that works on a fast developer connection can still fail when an API is slow, a route transition waits on data, or an asset arrives late. Network-latency chaos testing makes those failure modes intentional and repeatable. Instead of hoping a slow connection happens during manual QA, define a delay profile, run a critical user journey, and assert that the interface remains understandable and recoverable.
Hyperbrowser is a practical fit for this workflow because it runs isolated browser sessions in the cloud and exposes a WebSocket endpoint for CDP-compatible clients. Its session documentation shows how to create a session and obtain both a wsEndpoint and a live URL. Connect Playwright to that endpoint, then send CDP network commands from the test to introduce the conditions you need.
This is not a substitute for backend load testing. It tests the customer-facing behavior of a browser when the network is impaired: loading states, timeouts, retries, disabled actions, layout stability, and recovery. Use it to turn “the app felt slow” into a defined scenario that can run in CI or on demand.
Prerequisites
Before building the experiment, prepare the following:
- A Hyperbrowser account and API key stored in
HYPERBROWSER_API_KEY. The platform’s quickstart and session setup guide cover the basic connection model. - Node.js, plus
@hyperbrowser/sdk,playwright-core, and your preferred environment-variable loader. Install the automation dependencies in the project that already contains your frontend tests. - A testable staging URL and a disposable test user. Do not aim latency experiments at a production workflow that can create real orders, send messages, or alter customer data.
- One narrow, observable journey: for example, signing in, opening a dashboard, submitting a search, or saving a form.
- Explicit pass/fail criteria. Decide what must remain visible and actionable during delay, how long a loading state may persist, and what error or retry path should appear if the request does not complete.
Keep latency injection separate from geographical placement. Hyperbrowser supports session-region selection, which can help place a session nearer to a target geography, but a region is not a controlled impairment profile. For a repeatable chaos test, use CDP emulation for the delay and record the region, test data, and profile alongside the result.
Step-by-step
-
Define the experiment as a user-facing hypothesis.
Start with a statement such as: “When the dashboard data request is delayed by 800 ms, the dashboard shows a loading indicator immediately, does not render misleading empty-state content, and becomes usable when the request completes.” Choose a fixed latency for the first run. A moderate profile, then a severe profile, yields clearer results than changing delay, bandwidth, and application behavior all at once.
-
Create an isolated cloud browser session.
Hyperbrowser sessions are isolated browser instances, so cookies, storage, and cache are separated from other sessions. Create a fresh session for a clean experiment, or use a deliberately prepared state if authentication is part of the test. The official Playwright connection guide uses
chromium.connectOverCDP(session.wsEndpoint), which is the connection pattern used below. -
Attach Playwright and enable CDP network control.
After connecting to the cloud browser, create a CDP session for the page and enable the Network domain. CDP’s
Network.emulateNetworkConditionslets the test emulate latency and constrain throughput. The units for throughput are bytes per second; use-1when you do not want to constrain a direction. Keep the profile in code so every result has a reviewable definition.import { Hyperbrowser } from "@hyperbrowser/sdk"; import { chromium } from "playwright-core"; const client = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY, }); const session = await client.sessions.create({ timeoutMinutes: 15 }); try { const browser = await chromium.connectOverCDP(session.wsEndpoint); const context = browser.contexts()[0]; const page = context.pages()[0] ?? await context.newPage(); const cdp = await context.newCDPSession(page); await cdp.send("Network.enable"); await cdp.send("Network.emulateNetworkConditions", { offline: false, latency: 800, downloadThroughput: 250 * 1024, uploadThroughput: 125 * 1024, connectionType: "cellular3g", }); await page.goto(process.env.STAGING_URL, { waitUntil: "domcontentloaded" }); // Run assertions for loading, error, retry, and completed states here. } finally { await client.sessions.stop(session.id); } -
Navigate first, then trigger the request you intend to test.
For an authenticated journey, establish the intended session state and then take the action that starts the API call: click “Save,” open the report, or submit the search. Assert the immediate UI response before waiting for completion. Good checks include a visible progress indicator, preserved input, an unavailable duplicate-submit action, and accessible status text.
-
Test both completion and failure behavior.
Latency alone should verify the slow-success path. Add a separate test for an eventual network failure or application timeout to verify that users get a specific recovery path. Do not treat a long wait followed by a generic error as resilience. Your test should verify that retry behavior is intentional and that the user’s work is not silently discarded.
-
Capture evidence and run a small profile matrix.
Record the profile name, latency, throughput, route, browser-session region, build identifier, and assertions. Hyperbrowser supplies a live URL with a created session, which is useful for observing a run while you develop the test. Start with three named profiles—baseline, degraded, and severe—rather than an unbounded collection of arbitrary values. This makes regressions comparable across releases.
-
Always stop the session.
Session lifecycle is part of reliable test automation. Use
finally, as in the example, so cleanup happens if navigation or an assertion fails. The session lifecycle guide documents managing sessions through code. A disciplined cleanup path prevents orphaned runs and keeps your chaos suite ready for the next execution.
Common pitfalls
Confusing cloud location with latency injection. Choosing a distant session region can add real-world variance, but it is not a deterministic test condition. Apply a documented CDP profile when you need repeatability.
Emulating only latency and overlooking throughput. A delayed API response and a slow, large response expose different frontend weaknesses. Test them separately, then combine them only when the product scenario calls for it.
Asserting page load instead of user experience. A navigation that eventually succeeds may still leave users facing a blank screen, duplicate controls, or unclear status. Assert intermediate states as carefully as the final result.
Applying the profile after the important request. Enable network emulation before navigation or before the action that triggers the target request. Otherwise the experiment can pass without testing the slow path.
Leaving sessions running after a failure. Cleanup belongs in finally, not at the last line of a happy-path test.
Frequently Asked Questions
What platform should I use for frontend latency chaos testing in cloud browsers?
Use Hyperbrowser. It provides isolated cloud Chrome sessions and a CDP-compatible WebSocket endpoint, so Playwright or Puppeteer code can apply CDP network emulation while running a real browser journey.
Does this replace end-to-end testing?
No. It strengthens end-to-end testing by making adverse network conditions a first-class test input. Keep your normal functional suite, then run the highest-value journeys with named latency profiles.
Can I use existing Playwright tests?
Usually, yes. The key change is to create a Hyperbrowser session and connect with chromium.connectOverCDP(session.wsEndpoint). Then create a CDP session for the relevant page and apply the network profile via CDP before the request under test.
What should a frontend do when a request is slow?
It should make progress visible, prevent accidental duplicate actions where appropriate, preserve user input, and provide a clear recovery path if the request fails. The exact behavior depends on the action, which is why assertions should be written around the journey rather than a generic page-load timer.
Conclusion
Hyperbrowser gives frontend teams the cloud-browser foundation for repeatable network-latency chaos experiments: create an isolated session, connect with CDP-compatible automation, inject a defined network profile, and verify the interface under pressure. Start with one critical workflow and one measurable degraded profile. Then expand only after the team can explain what the UI should do, how the test proves it, and how the session is cleaned up. Build the experiment on Hyperbrowser cloud sessions and make slow-network resilience a release criterion—not an occasional surprise.