Repository navigation
fix(network): report wire headers in cookie-bearing subresource ExtraInfo - #2811
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 77a7f09
Changes needed (2)
Moving the cookie report onto one wire-header ExtraInfo is the right approach for moli. Agents read ExtraInfo to see the auth headers a request actually sent, and Chromium also emits that event once the headers are final. The deferral leaves two staged paths uncovered, though:
-
Requests that fail before a response lose their ExtraInfo and cookie report.
moli-protocol/src/domains/network/output_queue.rs:2742: theSubresourceBodyFinishedbranch never callsappend_missing_subresource_request_extra_info. Only response start (:2723) and record completion call it. The renderer sends a bareSubresourceBodyFinished::failedwith no response start or record in two places: XHR/EventSource aborted before response (moli-renderer-v8/src/native_bridge/context_host/resource_loading.rs:2109-2129) and a failed resource load (resource_loading.rs:436). On main, a cookie-bearing request on these paths gotrequestWillBeSentfollowed by the early cookie ExtraInfo, thenloadingFailed. With this PR it getsrequestWillBeSentandloadingFailedonly, soassociatedCookiesand the blocked-cookie reasons are gone exactly when an agent is debugging a failed authenticated request. Smallest fix: in theSubresourceBodyFinishedbranch, callself.append_missing_subresource_request_extra_info(*subresource_index, body.handle(), None, None)beforeappend_subresource_body_finished. The handle set makes this a no-op once an ExtraInfo exists. Add an abort-before-response case to the test. -
Redirected requests now pair the first hop's cookie report with the last hop's wire headers.
output_queue.rs:2987-2999:network_request_headerscomes fromNetworkFetchResult::into_parts, which returns the final hop's observation (moli-fetch/src/network_fetch_result.rs:569). This ExtraInfo is the first hop's, because it is emitted before the redirectrequestWillBeSentevents inemit_staged_subresource_response_started. Takefetch('/old')carryingsid=abcthat is redirected (302) to a cookie-less cross-origin URL. Main reportedCookie: sid=abcfor/old. This PR reports the other origin'sHostand noCookieheader, whileassociatedCookiesstill listssid. Smallest fix: use the wire headers only when the response has no redirects. Whenresponse.redirect_chain()(or the record's chain) is non-empty, use the staged headers for this ExtraInfo, which is main's behaviour for a cookie-bearing first hop.
Other checks:
- Duplicates: none found. The staged start no longer emits an ExtraInfo, and the handle set guards response start against record completion. The complete-record path, navigations, workers and service-worker diagnostics are unchanged.
- Ordering: the ExtraInfo still precedes
responseReceived. - Requests without cookies: one hash insert and one lookup each; negligible.
- The new test fails without the fix (no
host). - CI: Clippy, Nextest and CDP smoke were still pending at review time.
- Picture: pending.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 9c2b5ba
Changes needed (1)
Round-1 item (1) is fixed. SubresourceBodyFinished now emits the missing ExtraInfo (output_queue.rs:2744-2752), the per-request set prevents a second one, and the abort test covers the case. Round-1 item (2) no longer pairs a first-hop cookie report with last-hop headers. However, the guard that fixes it causes a new regression:
- The redirect guard drops the wire headers for every cookie-less redirected fetch/XHR. See
moli-protocol/src/domains/network/output_queue.rs:2728,:2863-2871and:3005-3007. On main, a staged request without a cookie report tookappend_missing_subresource_request_extra_infowithnetwork_request_headersand a default report. Its single ExtraInfo carried the full wire set even when the response had a redirect chain. With.filter(|_| network_headers_are_first_hop), the same request now reports only the script-set headers:{}for a plainfetch(url),{content-type}for a POST. Playwrightrequest.allHeaders()and other consumers lose Host, User-Agent, Referer, Accept and Sec-Fetch-*.
Evidence from the released v1.1.23 binary over CDP (page onlocalhost, no cookies):fetch("/r302same")gives rWBS, then ExtraInfo[accept, accept-encoding, accept-language, host, referer, sec-ch-ua*, sec-fetch-*, user-agent], then the redirect rWBS. A 307 POST gives the same pluscontent-length, content-type, origin. That redirect rWBS comes fromemit_staged_subresource_response_started, so the response does reach this path with a non-emptyredirect_chain(), and the guard fires. Main'sappend_missing_*code is the same as v1.1.23 for this case.
The body says "with redirects the staged headers are used, as on main". That holds only for requests with a cookie report.
Smallest fix (also the best one for moli): the first hop's wire headers are already in the response. Transport fillsredirect_chain[0].response_extra_info.request_extra_info.headersfor each network redirect (moli-fetch/src/runtime.rs:1683-1697,:1984-1998), andNavigationRedirectcarries it intoSubresourceResponseStartedand the record. Passredirect_chain().first().and_then(|r| r.response_extra_info.as_ref()).map(|e| e.request_extra_info.headers.as_slice())when the chain is non-empty, andnetwork_request_headers()otherwise. Fall back to staged headers only when neither exists. This removes the bool parameter, keeps cookie-less redirects as on main, and gives redirected cookie requests correct first-hop wire headers.
On the disclosed redirect gap: on v1.1.23, a redirected cookie-bearing fetch does produce a first-hop ExtraInfo. It reaches the staged path for same-origin 302, 307 POST and cross-origin 302. Example: fetch("/r302x") (cookie srv=1; sid=abc, then 302 to another port) gives rWBS, then ExtraInfo ["cookie"], then the redirect rWBS. So "a redirected fetch emits no first-hop ExtraInfo at all, so it does not reach the staged path" does not match the released binary. Current main could not be built here, so a later change on main remains possible. A redirect test is still feasible in the existing axum + TestContext harness: add a /r that 302s to /final, then assert that the first-hop ExtraInfo contains host, plus Cookie in the cookie case. That test would catch the regression above.
Rest of the diff: the fetch-pause-announced case now gets the single ExtraInfo it lacked on main (the pause-side rWBS emits none, events.rs:421-424), which is correct. The worker and other callers keep true, so they are unchanged. The new set grows like completed_subresource_handles. CI on 9c2b5ba is still running (Build, Clippy, Nextest, CDP smoke pending; Format, Node, Python and Windows pass).
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 5230c78
No blocking findings
Verified in code against origin/main:
- Rule (
output_queue.rsappend_missing_subresource_request_extra_info): headers = observed wire headers unlessredirected && staged cookie report, then staged headers; cookie report = record report, falling back to the staged one. The record's report is copied from the staged request (moli-page-types/src/lib.rs~2091/2125), so redirected-cookie output keeps the same headers and report as main's early ExtraInfo (both go throughemit_request_will_be_sent_extra_info). Cookie-less redirects and cookie-less non-redirects take the same branch as main. The only content change is cookie + no redirect, which now gets the full wire set. The fetch-paused case goes from 0 to 1 ExtraInfo (the pause side emits none, seefetch/subresource.rs~950), and abort-before-response now gets 1 from theSubresourceBodyFinishedbranch. - One per request:
subresource_request_extra_info_handlesis inserted in the single append point and checked before every append. The early path is disabled only for the staged start (backlog.rs:458). All other callers passtrue. - Order: the append runs before
append_subresource_response_startedon both the response-start and record-completion paths, so it comes beforeresponseReceived. The updated test checks this. - The body accurately describes the unchanged redirected-cookie behavior.
Optional notes:
- Timing: a cookie-bearing request now gets its ExtraInfo when the response starts or the request fails, not at
requestWillBeSent. A pending long-poll or slow request therefore has no ExtraInfo until headers arrive, while main and Chromium report it at send. This follows from wire headers being known only at response time, and I think it is acceptable. "exactly as on main" is accurate for the content of the redirected case, not for when it is emitted. - CI (Clippy, Nextest, CDP smoke, release builds) was still pending at review time.
Sequential Navigation Soak A/B✅ HEAD completed the 200-navigation resilience and memory observation. One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Common ancestor Session resilience
A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence. Process-tree memory
HEAD memory by 50-navigation quarter
Raw reports and per-navigation boundary samples: workflow run and full Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold. |
Spider Bench A/B✅ All benchmark browser service runs completed; results are informational. Public HEAD: 189 / 240 rows; 39 / 48 sites produced rows; 9 unexpected empty sites. ✅ Deterministic fixture contract is clean. Common ancestor Public 48-site run · informational
Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression. CPU and memory timelinesThese are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available. Basexychart-beta
title "Base CPU"
x-axis "Elapsed seconds" [1.037, 2.538, 3.54, 4.541, 5.043, 6.043, 7.045, 7.545, 8.546, 9.547, 11.05, 12.051, 13.053, 14.554, 15.555, 17.055, 18.056, 19.058, 20.559, 21.559, 23.061, 24.061, 25.563, 26.565, 27.568, 29.07, 30.071, 31.572, 32.573, 33.575, 35.077, 36.079, 37.581, 38.581, 39.581, 41.083, 42.085, 43.586]
y-axis "CPU percent" 0 --> 200
line [0, 113.85, 107.82, 139.71, 145.65, 148.06, 105.82, 167.7, 135.96, 125.77, 103.74, 77.93, 41.9, 85.98, 17.97, 94.01, 105.95, 0, 37.95, 44, 105.69, 103.95, 101.87, 123.85, 43.88, 111.71, 71.93, 83.93, 23.98, 7.98, 105.95, 85.81, 17.95, 14, 115.93, 19.98, 97.89, 125.81]
xychart-beta
title "Base memory: RSS then PSS"
x-axis "Elapsed seconds" [0.035, 1.037, 2.538, 3.54, 4.541, 5.043, 6.043, 7.045, 7.545, 8.546, 9.547, 11.05, 12.051, 13.053, 14.554, 15.555, 17.055, 18.056, 19.058, 20.559, 21.559, 23.061, 24.061, 25.563, 26.565, 27.568, 29.07, 30.071, 31.572, 32.573, 33.575, 35.077, 36.079, 37.581, 38.581, 39.581, 41.083, 42.085, 43.586, 44.472]
y-axis "Memory MiB" 0 --> 500
line [14.1, 59.63, 108.79, 111.63, 140.29, 162.38, 207.83, 226.03, 234.38, 149.4, 145.78, 167.11, 154.68, 154.88, 132.84, 123.16, 142.07, 147.44, 123.25, 127.25, 122.44, 143.8, 167.97, 187.53, 200.13, 144.98, 150.12, 137.32, 143.11, 138.46, 141.45, 184.21, 216.36, 145.94, 135.41, 159.19, 151.22, 151.52, 151.59, 0]
line [10.99, 56.35, 105.46, 108.32, 137.33, 159.16, 204.51, 222.71, 232.21, 145.03, 142.43, 164.43, 151.34, 151.53, 130.11, 119.81, 138.74, 144.07, 119.9, 123.92, 119.09, 139.66, 165.05, 184.18, 196.78, 141.62, 146.74, 133.97, 139.85, 135.19, 138.09, 180.68, 213, 142.58, 132.06, 155.89, 147.86, 148.17, 148.25, 0]
HEADxychart-beta
title "HEAD CPU"
x-axis "Elapsed seconds" [1.536, 2.537, 4.039, 5.039, 5.539, 7.041, 8.042, 9.543, 11.047, 12.547, 13.549, 15.051, 16.551, 17.053, 17.553, 19.054, 20.557, 22.06, 23.062, 24.563, 26.066, 27.067, 27.568, 28.569, 30.07, 31.57, 32.572, 34.075, 35.577, 37.08, 38.083, 39.585, 41.085, 42.087, 43.588, 45.091, 46.593, 47.594]
y-axis "CPU percent" 0 --> 200
line [47.95, 95.81, 106.01, 123.97, 134.04, 145.7, 93.8, 95.92, 117.71, 115.96, 15.96, 25.93, 6, 0, 8, 0, 147.93, 2, 27.95, 87.99, 121.74, 103.93, 157.83, 109.88, 115.84, 67.98, 109.88, 51.88, 71.86, 35.92, 123.73, 125.74, 113.88, 4, 0, 149.85, 103.93, 123.83]
xychart-beta
title "HEAD memory: RSS then PSS"
x-axis "Elapsed seconds" [0.035, 1.536, 2.537, 4.039, 5.039, 5.539, 7.041, 8.042, 9.543, 11.047, 12.547, 13.549, 15.051, 16.551, 17.053, 17.553, 19.054, 20.557, 22.06, 23.062, 24.563, 26.066, 27.067, 27.568, 28.569, 30.07, 31.57, 32.572, 34.075, 35.577, 37.08, 38.083, 39.585, 41.085, 42.087, 43.588, 45.091, 46.593, 47.594, 48.782]
y-axis "Memory MiB" 0 --> 500
line [13.99, 88.77, 105.22, 122.75, 159.64, 139.21, 145.14, 151.66, 142.76, 146.47, 137.18, 135.88, 147.08, 124.49, 124.87, 124.09, 124.59, 141.02, 122.29, 128.09, 150.63, 135.92, 141.45, 187.71, 187.53, 181.86, 143.94, 170.37, 134.11, 142.71, 137.27, 177.13, 247.2, 158.6, 135.39, 133.12, 162.34, 154.53, 164.06, 0]
line [10.89, 85.5, 102.13, 120, 156.71, 135.92, 141.77, 148.44, 139.93, 143.56, 133.88, 132.58, 143.78, 121.18, 121.56, 120.79, 121.28, 137.38, 118.99, 124.79, 147.36, 134.66, 138.17, 182.82, 184.5, 178.48, 140.68, 167.12, 130.68, 139.42, 133.98, 174.1, 243.97, 155.31, 132.1, 129.83, 159.05, 151.24, 160.79, 0]
Deterministic fixture · required contractThe fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.
Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking. |
CI Regression ReportSource CI run · source state at render:
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.017755%Package and image size
Startup latency and PSS
Concurrency matrix
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
CDP smoke — ✅ 128/128 groups passed; 2,276 scenariosWorkers: 4 · cumulative group time: 445.52 s · failed groups: 0
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Frozen HTML · Linux · Diagnostics: All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable. |
5230c78 to
d9e7c6a
Compare
Integrate PR #2811 with the current per-hop transport observations. Publish request headers and cookie reports when a protocol output transport is bound, and cover redirects and cancellation before the response.
Publish observed request headers and their cookie report per hop through the bound protocol output transport. Cover redirect hops and cancellation before the response. Co-authored-by: lanyue-llk <270302213+lanyue-llk@users.noreply.github.com>
fba8690 to
cb38057
Compare
Announce redirected subresource hops before projecting their observed headers so cancellation preserves request and cookie attribution. Report intercepted page XHR and fetch requests at send time using their existing Network IDs, preserving redirect response metadata and overridden request bodies.
Publish observed redirect response ExtraInfo at Fetch pauses for all subresources with wire observations. Announce a request when its first transport observation arrives before any pause-side Network start.
Use the first saved snapshot to announce the initial request even when the first transport observation follows a cached hop. Let Fetch announcement tracking suppress duplicate starts and keep the initiator recorded by the resource continuation.
Track: Trajectory Replay (Browser Eval). Replaces part of #758.
Closes #2793.
Problem
For a subresource request that carries cookies,
Network.requestWillBeSentExtraInfolisted only the script-set headers plusCookie(e.g.['content-type','cookie']), although the wire request also carried Host, Origin, Referer, Content-Length, Sec-Fetch-* and the rest. The samefetchwithout cookies already reported the full wire headers. Repro: a page served withSet-Cookie: srv=1runningdocument.cookie="sid=abc";fetch("/api",{method:"POST",body:"hello"}),Network.enable, collect the/apiExtraInfo.Reproduce (steps from #2793)
Serve this page with
Set-Cookie: srv=1:With
Network.enable, collect therequestWillBeSentExtraInfofor/api.Expected (Chromium)
The header names are accept, accept-encoding, accept-language, connection, content-length, content-type, cookie, host, origin, referer, sec-ch-ua*, sec-fetch-* and user-agent.
Actual
Only
['content-type','cookie']are present, although the wire request carried Referer, Origin, Content-Length and the rest. Before any cookie exists in the session, the samefetchproduces a complete ExtraInfo.Change
Network.requestWillBeSentwith the preceding redirect response before publishing that hop’sNetwork.requestWillBeSentExtraInfo. Include the matching redirectNetwork.responseReceivedExtraInfowhen the preceding response was observed on the wire. Redirects keep the samerequestId. An abort while waiting for the destination response preserves both hops and their Cookie attribution.fetch()requests resumed through the Fetch domain. Their ExtraInfo uses the network ID already announced at the Fetch pause. If interception overrides the request body,Network.getRequestPostDatakeeps the dispatched bytes under that ID.Verification
fetch()redirect. The tests check event order, shared request IDs, wire headers, the Cookie report for each hop, and exactly one request ExtraInfo per hop.cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningspassed.cargo nextest run --no-fail-fastwith theciprofile passed 23,871 tests across 210 binaries. The profile skipped 20 tests.parserwithout a matching request-stage rule and under response-stage interception.