Repository navigation
fix(browser): record the redirect answered to a request step - #8467
PranitSakhuja wants to merge 9 commits into
Conversation
A request step sends its fetch with manual redirect handling while a route guard is installed. Chromium then reports the request to Playwright as failed (net::ERR_ABORTED) with no response event, so the capture lost the redirect's status and Location even though network events and header values were selected, and the step error promised both. The browser still reports the answer on the Network domain (responseReceivedExtraInfo). Observe that for the step's own dispatch and present it to the network capture as the response Playwright withheld, ahead of the request-failed event. When the browser offers no such report, the existing opaque-redirect coverage disclosure still applies. The collector now records at most one response per request. Fixes morluto#7410 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ce5ff2abf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
[Medium impact] The PR appears safe to merge; no actionable issues remain from this review. SummaryThis PR records redirect responses that Playwright withholds from request-step captures. Redirects remain unfollowed, and recovered responses use the existing capture limits and redaction.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Attach redirect observer] --> B{Step still active?}
B -->|No| C[Stop observer and fail step]
B -->|Yes| D[Install route guard and send request]
D --> E[Offer recovered redirect to network capture]
E --> F[Fail step without following redirect]
F --> G[Stop observer and remove route guard]
Reviews (9) · Last reviewed commit: "fix(browser): recheck the step boundary ..." · Reviewed by Greptile |
Address review of morluto#8467: - Recover only 301/302/303/307/308. Fetch returns other 3xx answers, such as 300, as ordinary responses; a synthetic one would displace the real response and lose its body. - Withdraw the delivered claim when a second identical dispatch makes attribution ambiguous, so the step keeps disclosing the coverage gap. - Expand header arrays only when the capture asks for them. - Cover the late-attach release with a controlled slow attachment. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
Measure the raw redirect header report before building the normalized map or the repeated-value array, and decline recovery above Chromium's 256 KiB response-header ceiling so the step discloses the gap instead. Build the normalized map once, since the collector reads it for metadata and names. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e2afcd9f2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
… honestly Address second review of morluto#8467: - Remove the route guard before awaiting the bounded CDP detach, so a slow detach cannot keep aborting matching requests or consume the step deadline. - Stop retaining transport identities once attribution is ambiguous. - Say the browser reported the redirect to network capture rather than that the capture holds it: event budgets can still omit the event or its headers. Document the same in the contract. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 302cdb0525
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await withPlaywrightExecutionBoundary( | ||
| () => session.detach(), | ||
| REDIRECT_TRANSPORT_TIMEOUT_MS, | ||
| ).catch(() => undefined); |
There was a problem hiding this comment.
Retain ownership when CDP detach is unconfirmed
When CDPSession.detach() rejects or is still pending after the two-second boundary while the target remains live, this catch makes stop() succeed and drops the only redirect-session cleanup owner. Each later request step can then add another Network-enabled session, leaving unresolved event streams until the parent browser connection closes; retain or retry the unconfirmed detach through scenario cleanup rather than swallowing it.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this one, for the following reasons. Failure mode: detach() rejects or exceeds its 2s bound while the target stays live. Consequence: that one session stays Network-enabled and idle until the scenario ends; I checked that both launch and connect modes close the Playwright browser connection at scenario end (PlaywrightScenarioBrowser closeBrowser → browser.close()), which drops every CDP session, so it cannot outlive the scenario or touch the user's browser state beyond the connection. It does not hold the route, a lock, or any target state, and evidence is unaffected. Likelihood: low; detach of a live session is a single protocol call. Cost of the change: threading an AnalysisCleanupLease/retain owner through the request step, session and browser cleanup for a best-effort evidence aid. The storage CDP session uses a lease because it restores target state; this one holds none. Happy to add retention if a maintainer wants it, but I did not want to add that complexity speculatively (AGENTS.md asks for buy-in first).
A slow CDP attachment previously ran with the route guard already installed, so matching application traffic could be aborted after the step deadline while this step had not yet dispatched. Attach first, then install the route, and stop the observer if the route cannot be installed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3c5974d0c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Count the entries a redirect header report would expand to while measuring its raw size, and decline recovery above 4096 entries. A 256 KiB raw bound alone still allowed tens of thousands of tiny repeated fields to expand into several MB of entry objects before the capture's header budget applied. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 297a648114
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…esponses once Address review of morluto#8467: - Read requestWillBeSent with the existing CDP facts parser and add the matching responseReceivedExtraInfo parser beside it, so a malformed or version-skewed payload declines recovery instead of throwing out of the event dispatcher. - Track that a response was reported for a request independently of whether it was retained, so a refused first report is not omitted a second time when the browser's own report of the same answer follows. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0eda74c9d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The request-step redirect fallback also applies above 4,096 expanded header entries, not only above 256 KiB. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 094139f8c2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…uard Attaching the redirect observer first adds an await before page.route. If the step's deadline or cancellation fires during it, install no guard and stop the observer, using the same pre-dispatch check as before the attachment. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ecyy52XPaYusX4ko4WTbVe
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Friendly ping for a maintainer look when there's time. All checks pass, the Codex and Greptile findings are addressed, and the branch is mergeable. The redirect |
|
Hey @PranitSakhuja, thanks for putting this together, the fix looks useful. What's left: there are 13 unresolved review threads from Codex and Greptile (7 still on current code), e.g. "Restrict synthetic responses to Fetch redirect statuses" and "Avoid calling delivered redirects retained evidence"; the 6 on outdated lines may just need resolving if they're already handled. Happy to get this in once that's sorted out. |
|
Thanks for taking a look. I went through the threads: the ones that were fixed in follow-up commits (the 300 status, late ambiguity, header bounds, attach/route ordering, expiry recheck, CDP parsing, the duplicate omission, and the docs disclosure) have replies pointing at the fix, and I've now resolved them. All checks pass on the current head. One thread is left open on purpose: Codex asked to retain ownership of the CDP session when detach is unconfirmed. I did not add that, since both launch and connect modes close the browser connection at scenario end and the leftover session is idle. I'm happy to add retention if you'd prefer it, or you can resolve that thread if you agree. |
|
Thanks. This now conflicts with main in |
Summary
A
capture-browser-scenariorequest step that is answered with a redirect failed as intended, but its network evidence had noresponseevent, status orLocation, even with network events and header values selected. The step error anddocs/browser-scenario-contract.mdboth promise that evidence. This records the redirect's status andLocationas the request'sresponse.Fixes #7410
Problem and expected behavior
Smallest trigger: a GET request step to a loopback endpoint returning
302 Location: /destination, withcapture.events: ["network"]andnetwork.header_values: true.request,network-content,request-failed(net::ERR_ABORTED). No status, noLocation. Agotocontrol to the same URL records both.Locationremain in the capture.Cause (observed in a standalone probe, Chrome + Playwright 1.64.1): the request step installs a
page.routeguard. With interception active, Playwright emits noresponseevent for the manually handled redirect and reports the request as failed. Without the route it emitsresponse302 normally. Chrome'sNetwork.responseReceivedExtraInfostill reports status 302 andLocationin both cases.Change and scope
PlaywrightScenarioRedirect.tsobserves the Network domain for one request step's own dispatch (matched by URL and method) and, on a Fetch redirect status (301, 302, 303, 307, 308) with aLocationheader, presents it to the network collector as the withheld response. It does this when the browser reports it, so the response precedesrequest-failed, and the failed-request path then attaches header content as for any response. Body reads are never attempted (it rejects, and the failed path marks the body unavailable).PlaywrightScenarioNetwork.response()now records at most one response per request, so a recovered answer and a browser-reported one cannot both be emitted.gotocaptures.Contract and boundary impact
PlaywrightScenarioRequest) is the producer; the network collector and event capture consume. No superseded path removed; the fix(browser): disclose opaque redirect coverage gaps #7943 disclosure is retained as the fallback.responsenow include it.REA_BROWSER_EXECUTABLE.finally; a late attach is released when it settles.Expected effects:
Evidence and regression coverage
All executed, not source-derived.
Tests added or updated:
PlaywrightScenarioRedirect.test.ts(8: delivery and header shaping, either arrival order, non-redirects/foreign requests ignored, ambiguous dispatch, stop/detach, no transport, a slow attach released after the bounded wait, a claim withdrawn by a later identical dispatch, and a 300 answer left alone), a step-level test inPlaywrightScenarioRequest.test.ts(recovered redirect is delivered, no gap disclosed, session detached), a collector test for one response per request, and a mock update inPlaywrightScenarioSession.test.ts.Base reproduction or other evidence (real Chrome, loopback fixture, same scenario as the issue):
After-run repeated 3 times with identical results.
User-visible CLI/MCP output: the
capture-browser-scenarioJSON above.Remaining proof gaps: only GET + 302 in Chrome on macOS; write methods, other 3xx statuses,
connectmode and other Chromium builds were not run. The new unit tests use fakes for CDP; the real-browser result comes from the manual run above, not an automated test.For evidence-bearing changes:
Validation performed
npm run test:local -- <all src/browser/PlaywrightScenario*.test.ts and src/browser/network/*.test.ts>— 11 files, 316 tests passednpm run check:fast(typecheck, lint) — passednpm run verify:test-discovery— all 2943 test files discovered oncenpm run check:pr,docs:check, any non-Chrome or non-macOS browserCompatibility, safety, and release
Set-Cookie) pass through the existing header redaction and selection (header_values); nothing is captured when network events are not selected.Author readiness
Human owner: @PranitSakhuja
Before merge
type(scope): outcome.