You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: network route --delay <ms> to hold a matching request before continuing, aborting, or fulfilling it
#2314
Agent-driven QA of a web app on a local dev server. Several checks need one request to be slow while everything else stays fast:
Loading and skeleton states. On localhost an API call completes in 30 to 60 ms, so the state the team built never appears on a screenshot.
Request ordering. A page that fires the same endpoint several times (for example a list and a widget both calling /api/content-issue/list) should either serialize or cancel the stale one. You can only observe that by delaying one of the calls.
Timeout and retry paths in the client.
network route today can only abort a request or replace its response. Both produce an instant result, so none of the cases above are reachable from the CLI.
Today's options
set offline on and --abort are instant. They test the failure branch, not the slow branch.
Overriding window.fetch with an init script (--init-script) that reads rules from sessionStorage works for fetch and survives client-side navigation and reload. It does not see XHR, sendBeacon, resource loads, or server-side requests, and every project has to carry and maintain the shim.
Adding a setTimeout to the server route handler is invasive and is easy to leave behind.
--delay <ms> holds the paused request for the given time and then applies the rest of the rule: continue unchanged when no other flag is set, abort with --abort, or fulfill with --body. Routes that match the same URL keep their current precedence.
A related gap, probably a separate change: RouteEntry.response already carries status, contentType, and headers in the daemon, but the CLI only exposes --body. A --status <code> flag would cover the "API returns 500" case without a custom body.
Implementation hint
Routes are matched in the Fetch.requestPaused handler in cli/src/native/actions.rs. A delay: Option<u64> field on RouteEntry, parsed in handle_route from a delay parameter, and a tokio::time::sleep before the existing Fetch.continueRequest / Fetch.failRequest / Fetch.fulfillRequest call should be enough. The handler is a background task that consumes Fetch.requestPaused events in a loop, so the sleep needs its own spawned task per request; otherwise one delayed request would hold back every other paused request.
The CLI parser for network route is in cli/src/commands.rs next to --abort and --body. type already has a --delay <ms> flag with number validation that can be reused.
Environment
agent-browser 0.41.0, macOS (darwin arm64), Chrome via agent-browser install. Checked against a SvelteKit app and a Next.js app on localhost.
This discussion was converted from issue #2296 on November 03, 2026 06:46.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Use case
Agent-driven QA of a web app on a local dev server. Several checks need one request to be slow while everything else stays fast:
/api/content-issue/list) should either serialize or cancel the stale one. You can only observe that by delaying one of the calls.network routetoday can only abort a request or replace its response. Both produce an instant result, so none of the cases above are reachable from the CLI.Today's options
set offline onand--abortare instant. They test the failure branch, not the slow branch.window.fetchwith an init script (--init-script) that reads rules fromsessionStorageworks forfetchand survives client-side navigation andreload. It does not see XHR,sendBeacon, resource loads, or server-side requests, and every project has to carry and maintain the shim.setTimeoutto the server route handler is invasive and is easy to leave behind.Proposed
--delay <ms>holds the paused request for the given time and then applies the rest of the rule: continue unchanged when no other flag is set, abort with--abort, or fulfill with--body. Routes that match the same URL keep their current precedence.A related gap, probably a separate change:
RouteEntry.responsealready carriesstatus,contentType, andheadersin the daemon, but the CLI only exposes--body. A--status <code>flag would cover the "API returns 500" case without a custom body.Implementation hint
Routes are matched in the
Fetch.requestPausedhandler incli/src/native/actions.rs. Adelay: Option<u64>field onRouteEntry, parsed inhandle_routefrom adelayparameter, and atokio::time::sleepbefore the existingFetch.continueRequest/Fetch.failRequest/Fetch.fulfillRequestcall should be enough. The handler is a background task that consumesFetch.requestPausedevents in a loop, so the sleep needs its own spawned task per request; otherwise one delayed request would hold back every other paused request.The CLI parser for
network routeis incli/src/commands.rsnext to--abortand--body.typealready has a--delay <ms>flag with number validation that can be reused.Environment
agent-browser 0.41.0, macOS (darwin arm64), Chrome via
agent-browser install. Checked against a SvelteKit app and a Next.js app on localhost.All reactions