feat: add network wait subcommand for request-specific sync#866
Open
mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
Open
feat: add network wait subcommand for request-specific sync#866mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
mvanhorn wants to merge 3 commits intovercel-labs:mainfrom
Conversation
Add `network wait <url-pattern>` command that waits for a network response matching a URL pattern with optional --status, --method, and --timeout filters. Reuses existing CDP Network.responseReceived events with a poll-based timeout loop, matching the pattern used by handle_responsebody. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
The `:method` pseudo-header in response.requestHeaders only exists for HTTP/2 connections, causing --method filtering to silently fail on HTTP/1.1. Track methods from Network.requestWillBeSent events (which include request.method for all protocol versions) and look them up by requestId when processing Network.responseReceived. Co-Authored-By: Claude Opus 4.6 <[email protected]>
ctate
requested changes
Mar 17, 2026
Collaborator
ctate
left a comment
There was a problem hiding this comment.
Thanks for this! Waiting for specific network responses is a much-needed improvement over networkidle — nice work.
Two things to fix: First, the pretty text output (Matched: POST /api/login -> 200 (xhr)) never actually displays — the generic URL handler in output.rs catches it first. Moving the network_wait check above line 152 should do it. Second, the --follow flag for console/errors is parsed and documented here but the backend doesn't implement it — best to pull that out into its own PR.
…d --follow code Addresses @ctate's review: 1. Moved network_wait text output check above the generic URL handler in output.rs so "Matched: POST /api/login -> 200 (xhr)" displays correctly instead of being caught by the navigation response handler. 2. Removed --follow flag parsing and docs from this PR - that belongs in the separate console --follow PR (vercel-labs#867). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
Author
Contributor
Author
|
Both fixed in 4f5a6d5:
|
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
network wait <url-pattern>subcommand that waits for a network response matching a URL substring pattern--status <code>,--method <method>, and--timeout <ms>filtersNetwork.responseReceivedevent subscription (same pattern ashandle_responsebody)Motivation
AI agents need to wait for specific API responses before proceeding. Currently the only synchronization is
wait --load networkidle, which waits for ALL network activity to stop. For SPAs where background polling keeps the network active,networkidlenever resolves or resolves at the wrong time.Playwright has
page.waitForResponse(urlPattern)for this - agent-browser has no equivalent.Evidence
network requestsdoesn't capture document navigations - agents can't inspect what loadedUsage
Text output:
Matched: POST /api/login -> 200 (xhr)JSON output:
{"url":"https://example.com/api/login","method":"POST","status":200,"resourceType":"xhr"}Technical notes
Network.responseReceivedevents viamgr.client.subscribe(), matching the exact pattern used byhandle_responsebody(line ~4133)Network.enableif request tracking isn't already activenetwork requests --filter):methodrequest headerThis contribution was developed with AI assistance (Claude Code).