Skip to content

net: Start tracking timing info with FetchParams - #49040

Merged
TimvdLippe merged 1 commit into
servo:mainfrom
TimvdLippe:create-fetch-params-timing-info
Oct 19, 2026
Merged

TimvdLippe merged 1 commit into
servo:mainfrom
TimvdLippe:create-fetch-params-timing-info

Conversation

@TimvdLippe

Copy link
Copy Markdown
Contributor

The spec tracks timing info via the FetchParams rather than the Servo-specific FetchContext (which has no spec-equivalent struct).

This is the first PR that introduces the timing context and modifies in several places. In a follow-up other call-sides will also be migrated, however that requires more plumbing.

Part of #49036

Testing: no behavior change

@TimvdLippe TimvdLippe added the T-linux-wpt Do a try run of the WPT label Oct 19, 2026
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 19, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 19, 2026
@github-actions

Copy link
Copy Markdown

🔨 Triggering try run (#39262759241) for Linux (WPT)

@github-actions

Copy link
Copy Markdown

⚠️ Try run (#39262759241) cancelled.

@TimvdLippe
TimvdLippe force-pushed the create-fetch-params-timing-info branch from 6cdafeb to 16bbc02 Compare October 19, 2026 14:04
@TimvdLippe TimvdLippe added the T-linux-wpt Do a try run of the WPT label Oct 19, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Oct 19, 2026
@github-actions

Copy link
Copy Markdown

🔨 Triggering try run (#39265652812) for Linux (WPT)

The spec tracks timing info via the FetchParams rather than the
Servo-specific FetchContext (which has no spec-equivalent struct).

This is the first PR that introduces the timing context and modifies in
several places. In a follow-up other call-sides will also be migrated,
however that requires more plumbing.

Part of servo#49036

Testing: no behavior change

Signed-off-by: Tim van der Lippe <[email protected]>
@TimvdLippe
TimvdLippe force-pushed the create-fetch-params-timing-info branch from 16bbc02 to e7828ed Compare October 19, 2026 14:16
@github-actions

Copy link
Copy Markdown

Test results for linux-wpt from try job (#39265652812):

Flaky unexpected result (12)
  • CRASH [expected OK] /_webgl/conformance2/wasm/readpixels-2gb-in-4gb-wasm-memory.html
  • FAIL [expected PASS] /css/css-backgrounds/background-size-041.html
  • CRASH [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
  • CRASH [expected TIMEOUT] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • TIMEOUT [expected OK] /html/semantics/embedded-content/media-elements/autoplay-allowed-by-permissions-policy.https.sub.html (#46803)
    • TIMEOUT [expected PASS] subtest: Permissions-Policy header: autoplay * allows same-origin iframes.

      Test timed out
      

  • TIMEOUT [expected PASS] /html/semantics/embedded-content/the-img-element/sizes/sizes-auto-many-commas-crash.html
  • OK /html/semantics/forms/form-submission-0/jsurl-form-submit.tentative.html (#36489)
    • PASS [expected FAIL] subtest: Verifies that form submissions scheduled inside javascript: urls take precedence over the javascript: url's return value.
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • ERROR [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)
  • OK /preload/prefetch-document.html (#37210)
    • FAIL [expected PASS] subtest: different-site document prefetch with 'as=document' should not be consumed

      assert_equals: expected 2 but got 1
      

  • OK /upgrade-insecure-requests/gen/sharedworker-module-data.meta/unset/fetch.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to cross-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects blocked for fetch to same-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'blocked'. expected "blocked" but got "allowed"
      

  • OK /webxr/xrSession_features_deviceSupport.https.html (#24357)
    • FAIL [expected PASS] subtest: Immersive XRSession requests with no supported device should reject

      assert_unreached: Should have rejected: undefined Reached unreachable code
      

Stable unexpected results that are known to be intermittent (6)
  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove new parent

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self via innerHTML

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/refresh/same-document-refresh.html (#34597)
    • FAIL [expected PASS] subtest: Same-Document Referrer from Refresh

      assert_equals: original page loads expected "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section#section"
      

  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-button-click.html (#44099)
    • FAIL [expected TIMEOUT] subtest: Replace before load, triggered by submitButton.click()

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?thereplacement=" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/code-injector.html?pipe=sub(none)&amp;code=%0A%20%20%20%20const%20form%20%3D%20document.createElement(%22form%22)%3B%0A%20%20%20%20form.action%20%3D%20%22%2Fcommon%2Fblank.html%22%3B%0A%0A%20%20%20%20const%20input%20%3D%20document.createElement(%22input%22)%3B%0A%20%20%20%20input.type%20%3D%20%22hidden%22%3B%0A%20%20%20%20input.name%20%3D%20%22thereplacement%22%3B%0A%20%20%20%20form.append(input)%3B%0A%0A%20%20%20%20const%20button%20%3D%20document.createElement(%22button%22)%3B%0A%20%20%20%20button.type%20%3D%20%22submit%22%3B%0A%20%20%20%20form.append(button)%3B%0A%0A%20%20%20%20document.currentScript.before(form)%3B%0A%20%20%20%20button.click()%3B%0A%20%20"
      

  • TIMEOUT [expected OK] /html/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • OK /html/semantics/embedded-content/media-elements/media_fragment_seek.html (#24114)
    • PASS [expected FAIL] subtest: Video should seek to time specified in media fragment syntax
  • OK /html/semantics/forms/form-submission-0/form-submit-iframe-then-location-navigate.html (#29634)
    • FAIL [expected PASS] subtest: Verifies that location navigations take precedence when following form submissions.

      assert_equals: expected "/html/semantics/forms/form-submission-0/resources/location.html" but got "/html/semantics/forms/form-submission-0/resources/form.html"
      

@github-actions

Copy link
Copy Markdown

✨ Try run (#39265652812) succeeded.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 19, 2026
@TimvdLippe
TimvdLippe added this pull request to the merge queue Oct 19, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 19, 2026
Merged via the queue into servo:main with commit 8b8a8fe Oct 19, 2026
35 checks passed
@TimvdLippe
TimvdLippe deleted the create-fetch-params-timing-info branch October 19, 2026 18:02
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 19, 2026
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 22, 2026
A fetch can only be cancelled. When its player is full, a media element
cancels its fetch and later starts a new Range request. That throws away
the bytes in flight (about 2.5 MB per refill on an OpenHarmony board),
costs a new request and, on HTTP/1.1, a new connection, because a body
that is not read to its end cannot be drained. Gecko suspends the
channel instead, and Chromium defers loading.

Add FetchController::suspend and FetchController::resume. Like a
cancellation, they go through the fetch thread of the content process,
so they stay ordered after the start of the fetch, and reach the
resource thread as CoreResourceMsg::Suspend and CoreResourceMsg::Resume.
There they set the state of the request's CancellationListener, which
now keeps running, suspended or cancelled in a tokio watch channel.

The HTTP network fetch reads the body in a loop that, while the fetch
is suspended, waits for the state to change instead of polling the
body, so that TCP or HTTP/2 flow control holds back the server. Data
received before the suspension is still delivered, and after a resume
the body continues with the next byte. A cancellation wakes the loop at
once, also while it waits for data from the network; before, it was
only noticed when the next chunk arrived. If the connection fails or
closes while the fetch is suspended, the fetch ends after the resume as
an interrupted body does. The loop keeps what it did before: media
bodies are not kept, and a cancellation marks the response aborted
under the body lock.

Net bounds suspension itself, since it learns of no content process
that goes away and an unread body never sees its connection close. A
fetch that stays suspended for longer than the new pref
network_fetch_suspend_timeout_ms (60 s) ends with a network error, as
if its connection was lost. At most two fetches per origin are
suspended at once in each HTTP state, and a further suspension is
ignored: the fetches to an origin share an HTTP/2 connection, and every
suspended stream holds its stream window of the connection window, 2 of
5 MiB with hyper's defaults, so three would stall every other request
to the origin. A suspended fetch that is redirected moves to the new
origin, or is resumed if that has no place left. Suspension is advisory
and only takes effect while a body is read from the network: cache
hits, which are delivered in one chunk, data, file, blob and protocol
handler responses, and fetches that ended ignore it.

A fetch that waits in the HTTP cache for a body that another fetch is
still receiving treats a suspension of that fetch like an abort, and
goes to the network instead of waiting for the resume.

The responses of the redirects, authentication retries and CORS
preflight of a fetch share its listener, so while it is suspended, the
unread bodies of such responses hold their connection until the resume
or the deadline instead of being drained.

Fork note: meant for upstream. Drop once upstream has it.

Testing: unit tests with servers that stream a 64 MiB body and count
what they hand to the connection: a suspended fetch holds back the
server and receives the whole body intact after the resume, over
HTTP/1.1 and over HTTP/2 (TLS with ALPN, a new test server); a
cancellation ends a suspended fetch, and one that waits for a stalled
server, within a second; a fetch whose server closes the connection
while it is suspended ends after the resume with what was sent; the
deadline ends suspended fetches with a network error and frees their
places; a third suspension per origin is ignored and its server keeps
sending; fetches waiting in the HTTP cache for a suspended response go
to the network; FetchController suspends and resumes a fetch through
the fetch thread and the resource thread, and does nothing after the
end.

Validation: `./mach test-unit -p servo-net`: 412 tests pass (403 before), also with the suspension tests in one process. While a fetch was suspended, the server handed 4.9 MiB of a 64 MiB body to the connection over HTTP/1.1 and 2.1 MiB over HTTP/2. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` fetch/api/basic fetch/api/abort fetch/range fetch/http-cache xhr html/semantics/embedded-content/media-elements: 1034 tests, 1027 as expected; the other seven behave the same with the parent commit when run alone three times.
AI-assisted: Yes (agent session; implemented, tested and measured by the agent, reworked after a review by another agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- merged with upstream servo#49049 (fetch-thread `Cancel` with `forget`, `cancel_and_forget_async_fetch`) and servo#49040 (timing info in the fetch params): `Suspend` and `Resume` sit next to the new `Cancel` variant, the imports are joined, and the body loop takes its timing from `fetch_params.timing_info`. `./mach test-unit -p servo-net` at this commit: 412 tests pass)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 22, 2026
The HTTP cache kept every stored body as a `Vec<u8>` in the net process,
shared with the response handed to the consumer, so net also kept the
decoded body of every response until its fetch ended. Its RFC 9111
rules were hand-written for RFC 7234.

The rules now come from the `http-cache-rules` crate: storability, the
stored and updated header fields, freshness (with `max-age`, `Expires`,
the heuristic, `Age` and `Date`), `Vary`, `stale-while-revalidate`,
`immutable`, the request directives, the validation request and the
merge of a 304. The crate decides and stores nothing; its requirements
are traced to the RFC text and tested, model checked and fuzzed in its
own repository. `http_cache::policy` configures it as a private cache
that stores 206 responses and their bodies encoded.

Servo keeps what belongs to the fetch layer: the cache modes, background
revalidation (only for requests with a client), invalidation after
unsafe methods, ranges, and its own refusals on top of the crate: `Vary:
*`, entries over the store's size limit, 206 without `Content-Range`,
and the storage rule for audio and video of patch 79.

Storage moves behind `CacheStore`, which streams bodies in and out:

  * `TeeBody` copies each frame into the store below the content
    decoder, so the stored body is what came off the wire, and the copy
    is a reference count, not a second allocation. The store's bounded
    queue back-pressures the network.
  * A hit streams the entry through the decoder in chunks.
  * `ResponseBody::Streamed` marks a body delivered to the consumer and
    kept nowhere. Only subresource integrity and preloads still keep the
    whole decoded body (`retains_whole_body`), so net no longer keeps
    media bodies, which patch 79 had to arrange separately.
  * An entry is visible only once its decoded body ended cleanly, so a
    failed, cancelled or truncated body never becomes an entry, which
    patch 80 had to arrange separately. The fetch commits it through a
    `TeeCommit`, not `TeeBody` at the end of the network body: the
    decoder stops reading at the end of a gzip or brotli stream.
  * Every entry carries a random stamp, and the store opens, updates
    and removes an entry only for the stamp it was looked up with, since
    a later entry of the key may reuse its id.
  * `http_cache::inflight` lets one fetch write a key. Once its headers
    show a fresh response, others wait for it and read the committed
    entry, or go to the network if it aborts or, as patch 92 requires,
    while it is suspended. Before that, or if the response needs
    validation, they go to the network as with the old cache, so a slow
    or long-polled response holds up no other fetch. Once the whole body
    has arrived, they wait for any response while the store commits it,
    so a fetch right after another one finds its entry. A fetch does
    not wait for a response that varies on a field in which its own
    request differs, or whose body outgrows what the store accepts. It
    stops waiting when it is cancelled, and goes on from there like any
    cancelled fetch, and it waits 5 s at most.
  * `MemoryStore` is the only store in this patch: byte-bounded, LRU,
    for private browsing, temporary storage, no cache directory, and
    the tests. The SQLite cache goes, and `rusqlite`, `sea-query` and
    `quick_cache` leave `components/net`.

Fixes over the cache of the `http-cache-v2` branch, which this replaces:
a 304 no longer collapses repeated stored fields (a two-line CSP lost a
line) nor freshens on a weak or mismatching strong validator, `Age`
takes `Date` and the request time into account, the RFC 850 and asctime
date formats are understood, and `Vary` compares all field lines. That
branch also never stored a compressed response but stored a gzip body
cut short under clean framing, let a late 304 freshen or remove the
entry that had replaced its own, and made a fetch wait for the whole
body of another fetch's response even when it could not use it, and
wrote the URL's credentials into every entry: the key now leaves them
and the fragment out, and a stored response is served with the
request's URL. An
invalidation through `Location` or `Content-Location` reaches only URIs
of the target's origin (RFC 9111 4.4). Of several matching stored
responses the most recent is used (RFC 9111 4). When a 304 is about
another response than the stored one, the request is made again without
preconditions, and that response is stored.

Prefs: `network_http_cache_size` (an entry count) and
`network_http_disk_cache` (a path) are replaced by
`network_http_memory_cache_size` and `network_http_cache_max_entry_size`,
in bytes; `network_http_disk_cache_size` gains 0 = automatic.

`apply_algorithm_to_response` returned through `unreachable!()` when
the body was not `Done`, which a null body status makes it, and a
streamed body would reach reliably. It now returns a digest that cannot
match, so the fetch fails as `response-null-body.any.js` expects.

`preload/prefetch-document.html`: "different-site document prefetch with
'as=document' should not be consumed" now also fails at times, like its
two siblings. Servo has no HTTP cache partition (servo#33616), so the fresh
response of a cross-site prefetch answers the later navigation, unless
the navigation starts before the prefetch's response headers arrive and
goes to the network. With `network_http_cache_disabled=true` the subtest
passes and the "same origin ... should be consumed" sibling fails
instead.

Fork note: supersedes patches 79 and 80 (their cache code goes; their
fetch tests stay), and moves the cache side of patch 92 into
`http_cache::inflight`. 79 and 80 stayed on the stack at the 2026-10-22
sync: patch 92 builds on both (it calls 79's `may_store_media_response`
and sets 80's abort flag), so dropping them means reworking 92. Uses
`http-cache-rules` 0.1.0 from crates.io.

Testing: tests/http_cache.rs covers storability, Vary, freshness,
stale-while-revalidate with and without a client, partial entries and
ranges (with the five range tests of the `http-cache-range` branch),
the encoded body, the media storage rule, same-origin invalidation and
the most recent variant. tests/fetch.rs covers a 304 with another strong
validator, a 304 resetting Age, and a 304 with no-store.
tests/http_loader.rs covers a compressed response answered from the
cache, a compressed body cut short, and fetches that do not wait for the
headers of another fetch, a response that needs validation, a variant
of another request or a body too large to store, and that stop waiting
when cancelled or after a while; tests/http_cache.rs also a URL with
credentials and a fragment; tests/cache_store.rs an id reused by another
entry. The fetch tests of
patches 79, 80 and 92 are adapted to entries that appear on commit.

Validation: `./mach test-unit -p servo-net`: 435 tests pass. Negative controls, each run once: without the origin check, the most-recent selection, the 304 exception in `tee` or the suspended-producer wait, `test_invalidation_only_reaches_the_same_origin`, `test_the_most_recent_matching_response_is_used`, `test_a_304_for_another_response_makes_the_request_again_without_preconditions` and `test_fetch_waiting_for_a_suspended_response_uses_the_network` fail. Without the commit on the decoded end, the stamps and the waiting rule, `test_compressed_response_is_answered_from_cache`, `test_compressed_response_cut_short_is_not_stored`, `a_reused_id_is_not_touched_on_behalf_of_its_old_entry` (memory and disk store) and `test_fetch_does_not_wait_for_a_response_that_needs_validation` fail; with waiters waiting from the writer's registration on, `test_fetch_does_not_wait_for_the_headers_of_another_fetch` fails as well, and with waiters waiting for any response the validation one does. With patches 121 to 123: `./mach test-unit --profile checked-release` (1212 tests) and `--doc` pass; `./mach clippy --locked -- -- --deny warnings`, the crown `checked-release` build and the OHOS `checked-release` build with `RUSTFLAGS="-D warnings"` are clean, as is `./mach test-tidy`. WPT, `checked-release`, 8 processes, fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, cors, xhr, preload, html/semantics/embedded-content/media-elements and html/semantics/scripting-1, 2140 tests: 2134 as expected, and "Response with Cache-Control: max-age=2592000, public and Pragma: no-cache should not be cached" now passes (expectation removed; the crate's deviation D-2). The other six behave the same alone on ohos-main 091e100215c: src_object_blob.html times out 3 of 8 runs (2 of 8 there), load-removes-queued-error-event.html crashes 5 of 8 (4 of 8 there), media_fragment_seek.html fails and autoplay-default-permissions-policy.https.sub.html passes every time on both, and seek-to-max-value.htm and track-remove-by-setting-innerHTML.html pass 3 of 3 on both. Full WPT, `checked-release`, 12 processes, on the build before the waiting rule was fixed: 58273 of 58348 tests as expected. The other 75 were run again serially, those still unexpected on ohos-main 091e100215c too, and the 12 that differed 3 times alone on both: async_003.htm, async_004.htm and async_005.htm failed every time on the branch only (their script's headers are delayed, and a second fetch of it waited for them), and pass 3 of 3 with the fix; the other 9 behave the same on both. The focused set without scripting-1 on QuickJS (`--js-engine quickjs`), before the review fixes: 1540 of 1545 as expected, three of the same media tests, and two track-element timeouts that pass 3 of 3 alone on both builds. On ohos-main deaca97 with `http-cache-rules` 0.1.0 from crates.io (the same files as the path dependency tested above): `./mach test-unit -p servo-net` passes, 435 tests here and 472 with patch 121, and the CI-parity checks above pass again at patch 123, except `indexeddb::engines::sqlite::tests::test_async_operations` of servo-storage, which timed out once and passes 3 of 3 alone. `test_response_cache_status_is_validated` failed 5 of 320 runs, 32 at a time, while the commit of the first response was not waited for, and 0 of 960 after. WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, preload and html/semantics/scripting-1, 756 tests: as expected but for execution-timing/077.html, which passes 3 of 3 alone here and fails 1 of 3 alone on ohos-main 091e100215c, and the prefetch-document subtest above, which passed 2 of 3 runs alone; its expectation now allows both. Review fixes (the wait ends on cancellation, does not start for another variant or a body too large to store, and times out; the key leaves out the credentials and fragment of the URL): 440 tests pass here, and 481 with patch 121. Negative controls, each run once: without the cancellation of the wait, `test_a_waiting_fetch_stops_waiting_when_it_is_cancelled` fails; without the `Vary` check, the cap in `TeeBody`, the timeout or the password left out of the key, `test_fetch_does_not_wait_for_a_response_that_varies_from_its_request`, `test_fetch_does_not_wait_for_a_response_too_large_to_store`, `test_a_waiting_fetch_goes_to_the_network_after_a_while` and `test_url_credentials_and_fragment_are_not_part_of_the_key` fail. At patch 123 the CI-parity checks pass again (`test-unit --profile checked-release`: 1221 tests), and WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, preload, html/semantics/scripting-1 and html/semantics/embedded-content/media-elements, 1679 tests, run as expected but for four of the media tests above and seek-to-currentTime.html, which passes 3 of 3 alone on both builds. A first version also returned a network error from step 9 of HTTP-network-or-cache fetch for any fetch cancelled before it reached the network. PR CI caught that: requests sent while a document unloads were dropped, and fetch/fetch-later/send-on-discard/send-multiple, both sandbox-top-navigation-child-delivered tests, navigation-timing/nested-unload-timing and navigation-timing/prefetch-transfer-size-executor failed in both attempts of that CI run and in a serial local run. Without it they run as expected in 2 of 2 serial local runs; of the other stable unexpected results of that CI run, window-resize-event.html times out alone on ohos-main 091e100215c too, and test_resource_timing and media-loading-pseudo-classes-in-has.sub.html behave the same alone on both builds and are flaky upstream.
AI-assisted: Yes (agent session; the agent ported the storage half of the http-cache-v2 branch, wrote the glue over http-cache-rules and the merge with patches 79, 80 and 92, and wrote and ran the tests)
AI-assisted: Yes (agent session; 2026-10-22 sync -- conflict resolution: `http_cache.rs` deleted as before, which drops upstream's edits to it (servo#48927 most recent matching response and replacement of matching responses, servo#48842); this cache uses the most recent matching response already and makes the request again when a 304 is about another response. The old cache steps of HTTP-network-or-cache fetch and `block_for_cache_ready` go as before, with upstream's edits to them (servo#48927, servo#48867); `obtain_response` keeps upstream's new `FetchParams` signature (servo#49040) and returns the body below the decoder as before; test imports merged. `./mach test-unit -p servo-net` at this commit: 440 tests pass)
AI-assisted: Yes (agent session; 2026-10-22 sync -- the fork note says why patches 79 and 80 were not dropped)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 30, 2026
A fetch can only be cancelled. When its player is full, a media element
cancels its fetch and later starts a new Range request. That throws away
the bytes in flight (about 2.5 MB per refill on an OpenHarmony board),
costs a new request and, on HTTP/1.1, a new connection, because a body
that is not read to its end cannot be drained. Gecko suspends the
channel instead, and Chromium defers loading.

Add FetchController::suspend and FetchController::resume. Like a
cancellation, they go through the fetch thread of the content process,
so they stay ordered after the start of the fetch, and reach the
resource thread as CoreResourceMsg::Suspend and CoreResourceMsg::Resume.
There they set the state of the request's CancellationListener, which
now keeps running, suspended or cancelled in a tokio watch channel.

The HTTP network fetch reads the body in a loop that, while the fetch
is suspended, waits for the state to change instead of polling the
body, so that TCP or HTTP/2 flow control holds back the server. Data
received before the suspension is still delivered, and after a resume
the body continues with the next byte. A cancellation wakes the loop at
once, also while it waits for data from the network; before, it was
only noticed when the next chunk arrived. If the connection fails or
closes while the fetch is suspended, the fetch ends after the resume as
an interrupted body does. The loop keeps what it did before: media
bodies are not kept, and a cancellation marks the response aborted
under the body lock.

Net bounds suspension itself, since it learns of no content process
that goes away and an unread body never sees its connection close. A
fetch that stays suspended for longer than the new pref
network_fetch_suspend_timeout_ms (60 s) ends with a network error, as
if its connection was lost. At most two fetches per origin are
suspended at once in each HTTP state, and a further suspension is
ignored: the fetches to an origin share an HTTP/2 connection, and every
suspended stream holds its stream window of the connection window, 2 of
5 MiB with hyper's defaults, so three would stall every other request
to the origin. A suspended fetch that is redirected moves to the new
origin, or is resumed if that has no place left. Suspension is advisory
and only takes effect while a body is read from the network: cache
hits, which are delivered in one chunk, data, file, blob and protocol
handler responses, and fetches that ended ignore it.

A fetch that waits in the HTTP cache for a body that another fetch is
still receiving treats a suspension of that fetch like an abort, and
goes to the network instead of waiting for the resume.

The responses of the redirects, authentication retries and CORS
preflight of a fetch share its listener, so while it is suspended, the
unread bodies of such responses hold their connection until the resume
or the deadline instead of being drained.

Fork note: meant for upstream. Drop once upstream has it.

Testing: unit tests with servers that stream a 64 MiB body and count
what they hand to the connection: a suspended fetch holds back the
server and receives the whole body intact after the resume, over
HTTP/1.1 and over HTTP/2 (TLS with ALPN, a new test server); a
cancellation ends a suspended fetch, and one that waits for a stalled
server, within a second; a fetch whose server closes the connection
while it is suspended ends after the resume with what was sent; the
deadline ends suspended fetches with a network error and frees their
places; a third suspension per origin is ignored and its server keeps
sending; fetches waiting in the HTTP cache for a suspended response go
to the network; FetchController suspends and resumes a fetch through
the fetch thread and the resource thread, and does nothing after the
end.

Validation: `./mach test-unit -p servo-net`: 412 tests pass (403 before), also with the suspension tests in one process. While a fetch was suspended, the server handed 4.9 MiB of a 64 MiB body to the connection over HTTP/1.1 and 2.1 MiB over HTTP/2. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` fetch/api/basic fetch/api/abort fetch/range fetch/http-cache xhr html/semantics/embedded-content/media-elements: 1034 tests, 1027 as expected; the other seven behave the same with the parent commit when run alone three times.
AI-assisted: Yes (agent session; implemented, tested and measured by the agent, reworked after a review by another agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- merged with upstream servo#49049 (fetch-thread `Cancel` with `forget`, `cancel_and_forget_async_fetch`) and servo#49040 (timing info in the fetch params): `Suspend` and `Resume` sit next to the new `Cancel` variant, the imports are joined, and the body loop takes its timing from `fetch_params.timing_info`. `./mach test-unit -p servo-net` at this commit: 412 tests pass)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 30, 2026
The HTTP cache kept every stored body as a `Vec<u8>` in the net process,
shared with the response handed to the consumer, so net also kept the
decoded body of every response until its fetch ended. Its RFC 9111
rules were hand-written for RFC 7234.

The rules now come from the `http-cache-rules` crate: storability, the
stored and updated header fields, freshness (with `max-age`, `Expires`,
the heuristic, `Age` and `Date`), `Vary`, `stale-while-revalidate`,
`immutable`, the request directives, the validation request and the
merge of a 304. The crate decides and stores nothing; its requirements
are traced to the RFC text and tested, model checked and fuzzed in its
own repository. `http_cache::policy` configures it as a private cache
that stores 206 responses and their bodies encoded.

Servo keeps what belongs to the fetch layer: the cache modes, background
revalidation (only for requests with a client), invalidation after
unsafe methods, ranges, and its own refusals on top of the crate: `Vary:
*`, entries over the store's size limit, 206 without `Content-Range`,
and the storage rule for audio and video of patch 79.

Storage moves behind `CacheStore`, which streams bodies in and out:

  * `TeeBody` copies each frame into the store below the content
    decoder, so the stored body is what came off the wire, and the copy
    is a reference count, not a second allocation. The store's bounded
    queue back-pressures the network.
  * A hit streams the entry through the decoder in chunks.
  * `ResponseBody::Streamed` marks a body delivered to the consumer and
    kept nowhere. Only subresource integrity and preloads still keep the
    whole decoded body (`retains_whole_body`), so net no longer keeps
    media bodies, which patch 79 had to arrange separately.
  * An entry is visible only once its decoded body ended cleanly, so a
    failed, cancelled or truncated body never becomes an entry, which
    patch 80 had to arrange separately. The fetch commits it through a
    `TeeCommit`, not `TeeBody` at the end of the network body: the
    decoder stops reading at the end of a gzip or brotli stream.
  * Every entry carries a random stamp, and the store opens, updates
    and removes an entry only for the stamp it was looked up with, since
    a later entry of the key may reuse its id.
  * `http_cache::inflight` lets one fetch write a key. Once its headers
    show a fresh response, others wait for it and read the committed
    entry, or go to the network if it aborts or, as patch 92 requires,
    while it is suspended. Before that, or if the response needs
    validation, they go to the network as with the old cache, so a slow
    or long-polled response holds up no other fetch. Once the whole body
    has arrived, they wait for any response while the store commits it,
    so a fetch right after another one finds its entry. A fetch does
    not wait for a response that varies on a field in which its own
    request differs, or whose body outgrows what the store accepts. It
    stops waiting when it is cancelled, and goes on from there like any
    cancelled fetch, and it waits 5 s at most.
  * `MemoryStore` is the only store in this patch: byte-bounded, LRU,
    for private browsing, temporary storage, no cache directory, and
    the tests. The SQLite cache goes, and `rusqlite`, `sea-query` and
    `quick_cache` leave `components/net`.

Fixes over the cache of the `http-cache-v2` branch, which this replaces:
a 304 no longer collapses repeated stored fields (a two-line CSP lost a
line) nor freshens on a weak or mismatching strong validator, `Age`
takes `Date` and the request time into account, the RFC 850 and asctime
date formats are understood, and `Vary` compares all field lines. That
branch also never stored a compressed response but stored a gzip body
cut short under clean framing, let a late 304 freshen or remove the
entry that had replaced its own, and made a fetch wait for the whole
body of another fetch's response even when it could not use it, and
wrote the URL's credentials into every entry: the key now leaves them
and the fragment out, and a stored response is served with the
request's URL. An
invalidation through `Location` or `Content-Location` reaches only URIs
of the target's origin (RFC 9111 4.4). Of several matching stored
responses the most recent is used (RFC 9111 4). When a 304 is about
another response than the stored one, the request is made again without
preconditions, and that response is stored.

Prefs: `network_http_cache_size` (an entry count) and
`network_http_disk_cache` (a path) are replaced by
`network_http_memory_cache_size` and `network_http_cache_max_entry_size`,
in bytes; `network_http_disk_cache_size` gains 0 = automatic.

`apply_algorithm_to_response` returned through `unreachable!()` when
the body was not `Done`, which a null body status makes it, and a
streamed body would reach reliably. It now returns a digest that cannot
match, so the fetch fails as `response-null-body.any.js` expects.

`preload/prefetch-document.html`: "different-site document prefetch with
'as=document' should not be consumed" now also fails at times, like its
two siblings. Servo has no HTTP cache partition (servo#33616), so the fresh
response of a cross-site prefetch answers the later navigation, unless
the navigation starts before the prefetch's response headers arrive and
goes to the network. With `network_http_cache_disabled=true` the subtest
passes and the "same origin ... should be consumed" sibling fails
instead.

Fork note: supersedes patches 79 and 80 (their cache code goes; their
fetch tests stay), and moves the cache side of patch 92 into
`http_cache::inflight`. 79 and 80 stayed on the stack at the 2026-10-22
sync: patch 92 builds on both (it calls 79's `may_store_media_response`
and sets 80's abort flag), so dropping them means reworking 92. Uses
`http-cache-rules` 0.1.0 from crates.io.

Testing: tests/http_cache.rs covers storability, Vary, freshness,
stale-while-revalidate with and without a client, partial entries and
ranges (with the five range tests of the `http-cache-range` branch),
the encoded body, the media storage rule, same-origin invalidation and
the most recent variant. tests/fetch.rs covers a 304 with another strong
validator, a 304 resetting Age, and a 304 with no-store.
tests/http_loader.rs covers a compressed response answered from the
cache, a compressed body cut short, and fetches that do not wait for the
headers of another fetch, a response that needs validation, a variant
of another request or a body too large to store, and that stop waiting
when cancelled or after a while; tests/http_cache.rs also a URL with
credentials and a fragment; tests/cache_store.rs an id reused by another
entry. The fetch tests of
patches 79, 80 and 92 are adapted to entries that appear on commit.

Validation: `./mach test-unit -p servo-net`: 435 tests pass. Negative controls, each run once: without the origin check, the most-recent selection, the 304 exception in `tee` or the suspended-producer wait, `test_invalidation_only_reaches_the_same_origin`, `test_the_most_recent_matching_response_is_used`, `test_a_304_for_another_response_makes_the_request_again_without_preconditions` and `test_fetch_waiting_for_a_suspended_response_uses_the_network` fail. Without the commit on the decoded end, the stamps and the waiting rule, `test_compressed_response_is_answered_from_cache`, `test_compressed_response_cut_short_is_not_stored`, `a_reused_id_is_not_touched_on_behalf_of_its_old_entry` (memory and disk store) and `test_fetch_does_not_wait_for_a_response_that_needs_validation` fail; with waiters waiting from the writer's registration on, `test_fetch_does_not_wait_for_the_headers_of_another_fetch` fails as well, and with waiters waiting for any response the validation one does. With patches 121 to 123: `./mach test-unit --profile checked-release` (1212 tests) and `--doc` pass; `./mach clippy --locked -- -- --deny warnings`, the crown `checked-release` build and the OHOS `checked-release` build with `RUSTFLAGS="-D warnings"` are clean, as is `./mach test-tidy`. WPT, `checked-release`, 8 processes, fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, cors, xhr, preload, html/semantics/embedded-content/media-elements and html/semantics/scripting-1, 2140 tests: 2134 as expected, and "Response with Cache-Control: max-age=2592000, public and Pragma: no-cache should not be cached" now passes (expectation removed; the crate's deviation D-2). The other six behave the same alone on ohos-main 091e100215c: src_object_blob.html times out 3 of 8 runs (2 of 8 there), load-removes-queued-error-event.html crashes 5 of 8 (4 of 8 there), media_fragment_seek.html fails and autoplay-default-permissions-policy.https.sub.html passes every time on both, and seek-to-max-value.htm and track-remove-by-setting-innerHTML.html pass 3 of 3 on both. Full WPT, `checked-release`, 12 processes, on the build before the waiting rule was fixed: 58273 of 58348 tests as expected. The other 75 were run again serially, those still unexpected on ohos-main 091e100215c too, and the 12 that differed 3 times alone on both: async_003.htm, async_004.htm and async_005.htm failed every time on the branch only (their script's headers are delayed, and a second fetch of it waited for them), and pass 3 of 3 with the fix; the other 9 behave the same on both. The focused set without scripting-1 on QuickJS (`--js-engine quickjs`), before the review fixes: 1540 of 1545 as expected, three of the same media tests, and two track-element timeouts that pass 3 of 3 alone on both builds. On ohos-main deaca97 with `http-cache-rules` 0.1.0 from crates.io (the same files as the path dependency tested above): `./mach test-unit -p servo-net` passes, 435 tests here and 472 with patch 121, and the CI-parity checks above pass again at patch 123, except `indexeddb::engines::sqlite::tests::test_async_operations` of servo-storage, which timed out once and passes 3 of 3 alone. `test_response_cache_status_is_validated` failed 5 of 320 runs, 32 at a time, while the commit of the first response was not waited for, and 0 of 960 after. WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, preload and html/semantics/scripting-1, 756 tests: as expected but for execution-timing/077.html, which passes 3 of 3 alone here and fails 1 of 3 alone on ohos-main 091e100215c, and the prefetch-document subtest above, which passed 2 of 3 runs alone; its expectation now allows both. Review fixes (the wait ends on cancellation, does not start for another variant or a body too large to store, and times out; the key leaves out the credentials and fragment of the URL): 440 tests pass here, and 481 with patch 121. Negative controls, each run once: without the cancellation of the wait, `test_a_waiting_fetch_stops_waiting_when_it_is_cancelled` fails; without the `Vary` check, the cap in `TeeBody`, the timeout or the password left out of the key, `test_fetch_does_not_wait_for_a_response_that_varies_from_its_request`, `test_fetch_does_not_wait_for_a_response_too_large_to_store`, `test_a_waiting_fetch_goes_to_the_network_after_a_while` and `test_url_credentials_and_fragment_are_not_part_of_the_key` fail. At patch 123 the CI-parity checks pass again (`test-unit --profile checked-release`: 1221 tests), and WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, preload, html/semantics/scripting-1 and html/semantics/embedded-content/media-elements, 1679 tests, run as expected but for four of the media tests above and seek-to-currentTime.html, which passes 3 of 3 alone on both builds. A first version also returned a network error from step 9 of HTTP-network-or-cache fetch for any fetch cancelled before it reached the network. PR CI caught that: requests sent while a document unloads were dropped, and fetch/fetch-later/send-on-discard/send-multiple, both sandbox-top-navigation-child-delivered tests, navigation-timing/nested-unload-timing and navigation-timing/prefetch-transfer-size-executor failed in both attempts of that CI run and in a serial local run. Without it they run as expected in 2 of 2 serial local runs; of the other stable unexpected results of that CI run, window-resize-event.html times out alone on ohos-main 091e100215c too, and test_resource_timing and media-loading-pseudo-classes-in-has.sub.html behave the same alone on both builds and are flaky upstream.
AI-assisted: Yes (agent session; the agent ported the storage half of the http-cache-v2 branch, wrote the glue over http-cache-rules and the merge with patches 79, 80 and 92, and wrote and ran the tests)
AI-assisted: Yes (agent session; 2026-10-22 sync -- conflict resolution: `http_cache.rs` deleted as before, which drops upstream's edits to it (servo#48927 most recent matching response and replacement of matching responses, servo#48842); this cache uses the most recent matching response already and makes the request again when a 304 is about another response. The old cache steps of HTTP-network-or-cache fetch and `block_for_cache_ready` go as before, with upstream's edits to them (servo#48927, servo#48867); `obtain_response` keeps upstream's new `FetchParams` signature (servo#49040) and returns the body below the decoder as before; test imports merged. `./mach test-unit -p servo-net` at this commit: 440 tests pass)
AI-assisted: Yes (agent session; 2026-10-22 sync -- the fork note says why patches 79 and 80 were not dropped)
AI-assisted: Yes (agent session; 2026-10-29 sync -- test compile fix: `request_with_client()` sets the new `RequestClient::network_partition_key` (servo#49252))
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
A fetch can only be cancelled. When its player is full, a media element
cancels its fetch and later starts a new Range request. That throws away
the bytes in flight (about 2.5 MB per refill on an OpenHarmony board),
costs a new request and, on HTTP/1.1, a new connection, because a body
that is not read to its end cannot be drained. Gecko suspends the
channel instead, and Chromium defers loading.

Add FetchController::suspend and FetchController::resume. Like a
cancellation, they go through the fetch thread of the content process,
so they stay ordered after the start of the fetch, and reach the
resource thread as CoreResourceMsg::Suspend and CoreResourceMsg::Resume.
There they set the state of the request's CancellationListener, which
now keeps running, suspended or cancelled in a tokio watch channel.

The HTTP network fetch reads the body in a loop that, while the fetch
is suspended, waits for the state to change instead of polling the
body, so that TCP or HTTP/2 flow control holds back the server. Data
received before the suspension is still delivered, and after a resume
the body continues with the next byte. A cancellation wakes the loop at
once, also while it waits for data from the network; before, it was
only noticed when the next chunk arrived. If the connection fails or
closes while the fetch is suspended, the fetch ends after the resume as
an interrupted body does. The loop keeps what it did before: media
bodies are not kept, and a cancellation marks the response aborted
under the body lock.

Net bounds suspension itself, since it learns of no content process
that goes away and an unread body never sees its connection close. A
fetch that stays suspended for longer than the new pref
network_fetch_suspend_timeout_ms (60 s) ends with a network error, as
if its connection was lost. At most two fetches per origin are
suspended at once in each HTTP state, and a further suspension is
ignored: the fetches to an origin share an HTTP/2 connection, and every
suspended stream holds its stream window of the connection window, 2 of
5 MiB with hyper's defaults, so three would stall every other request
to the origin. A suspended fetch that is redirected moves to the new
origin, or is resumed if that has no place left. Suspension is advisory
and only takes effect while a body is read from the network: cache
hits, which are delivered in one chunk, data, file, blob and protocol
handler responses, and fetches that ended ignore it.

A fetch that waits in the HTTP cache for a body that another fetch is
still receiving treats a suspension of that fetch like an abort, and
goes to the network instead of waiting for the resume.

The responses of the redirects, authentication retries and CORS
preflight of a fetch share its listener, so while it is suspended, the
unread bodies of such responses hold their connection until the resume
or the deadline instead of being drained.

Fork note: meant for upstream. Drop once upstream has it.

Testing: unit tests with servers that stream a 64 MiB body and count
what they hand to the connection: a suspended fetch holds back the
server and receives the whole body intact after the resume, over
HTTP/1.1 and over HTTP/2 (TLS with ALPN, a new test server); a
cancellation ends a suspended fetch, and one that waits for a stalled
server, within a second; a fetch whose server closes the connection
while it is suspended ends after the resume with what was sent; the
deadline ends suspended fetches with a network error and frees their
places; a third suspension per origin is ignored and its server keeps
sending; fetches waiting in the HTTP cache for a suspended response go
to the network; FetchController suspends and resumes a fetch through
the fetch thread and the resource thread, and does nothing after the
end.

Validation: `./mach test-unit -p servo-net`: 412 tests pass (403 before), also with the suspension tests in one process. While a fetch was suspended, the server handed 4.9 MiB of a 64 MiB body to the connection over HTTP/1.1 and 2.1 MiB over HTTP/2. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` fetch/api/basic fetch/api/abort fetch/range fetch/http-cache xhr html/semantics/embedded-content/media-elements: 1034 tests, 1027 as expected; the other seven behave the same with the parent commit when run alone three times.
AI-assisted: Yes (agent session; implemented, tested and measured by the agent, reworked after a review by another agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- merged with upstream servo#49049 (fetch-thread `Cancel` with `forget`, `cancel_and_forget_async_fetch`) and servo#49040 (timing info in the fetch params): `Suspend` and `Resume` sit next to the new `Cancel` variant, the imports are joined, and the body loop takes its timing from `fetch_params.timing_info`. `./mach test-unit -p servo-net` at this commit: 412 tests pass)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
The HTTP cache kept every stored body as a `Vec<u8>` in the net process,
shared with the response handed to the consumer, so net also kept the
decoded body of every response until its fetch ended. Its RFC 9111
rules were hand-written for RFC 7234.

The rules now come from the `http-cache-rules` crate: storability, the
stored and updated header fields, freshness (with `max-age`, `Expires`,
the heuristic, `Age` and `Date`), `Vary`, `stale-while-revalidate`,
`immutable`, the request directives, the validation request and the
merge of a 304. The crate decides and stores nothing; its requirements
are traced to the RFC text and tested, model checked and fuzzed in its
own repository. `http_cache::policy` configures it as a private cache
that stores 206 responses and their bodies encoded.

Servo keeps what belongs to the fetch layer: the cache modes, background
revalidation (only for requests with a client), invalidation after
unsafe methods, ranges, and its own refusals on top of the crate: `Vary:
*`, entries over the store's size limit, 206 without `Content-Range`,
and the storage rule for audio and video of patch 79.

Storage moves behind `CacheStore`, which streams bodies in and out:

  * `TeeBody` copies each frame into the store below the content
    decoder, so the stored body is what came off the wire, and the copy
    is a reference count, not a second allocation. The store's bounded
    queue back-pressures the network.
  * A hit streams the entry through the decoder in chunks.
  * `ResponseBody::Streamed` marks a body delivered to the consumer and
    kept nowhere. Only subresource integrity and preloads still keep the
    whole decoded body (`retains_whole_body`), so net no longer keeps
    media bodies, which patch 79 had to arrange separately.
  * An entry is visible only once its decoded body ended cleanly, so a
    failed, cancelled or truncated body never becomes an entry, which
    patch 80 had to arrange separately. The fetch commits it through a
    `TeeCommit`, not `TeeBody` at the end of the network body: the
    decoder stops reading at the end of a gzip or brotli stream.
  * Every entry carries a random stamp, and the store opens, updates
    and removes an entry only for the stamp it was looked up with, since
    a later entry of the key may reuse its id.
  * `http_cache::inflight` lets one fetch write a key. Once its headers
    show a fresh response, others wait for it and read the committed
    entry, or go to the network if it aborts or, as patch 92 requires,
    while it is suspended. Before that, or if the response needs
    validation, they go to the network as with the old cache, so a slow
    or long-polled response holds up no other fetch. Once the whole body
    has arrived, they wait for any response while the store commits it,
    so a fetch right after another one finds its entry. A fetch does
    not wait for a response that varies on a field in which its own
    request differs, or whose body outgrows what the store accepts. It
    stops waiting when it is cancelled, and goes on from there like any
    cancelled fetch, and it waits 5 s at most.
  * `MemoryStore` is the only store in this patch: byte-bounded, LRU,
    for private browsing, temporary storage, no cache directory, and
    the tests. The SQLite cache goes, and `rusqlite`, `sea-query` and
    `quick_cache` leave `components/net`.

Fixes over the cache of the `http-cache-v2` branch, which this replaces:
a 304 no longer collapses repeated stored fields (a two-line CSP lost a
line) nor freshens on a weak or mismatching strong validator, `Age`
takes `Date` and the request time into account, the RFC 850 and asctime
date formats are understood, and `Vary` compares all field lines. That
branch also never stored a compressed response but stored a gzip body
cut short under clean framing, let a late 304 freshen or remove the
entry that had replaced its own, and made a fetch wait for the whole
body of another fetch's response even when it could not use it, and
wrote the URL's credentials into every entry: the key now leaves them
and the fragment out, and a stored response is served with the
request's URL. An
invalidation through `Location` or `Content-Location` reaches only URIs
of the target's origin (RFC 9111 4.4). Of several matching stored
responses the most recent is used (RFC 9111 4). When a 304 is about
another response than the stored one, the request is made again without
preconditions, and that response is stored.

Prefs: `network_http_cache_size` (an entry count) and
`network_http_disk_cache` (a path) are replaced by
`network_http_memory_cache_size` and `network_http_cache_max_entry_size`,
in bytes; `network_http_disk_cache_size` gains 0 = automatic.

`apply_algorithm_to_response` returned through `unreachable!()` when
the body was not `Done`, which a null body status makes it, and a
streamed body would reach reliably. It now returns a digest that cannot
match, so the fetch fails as `response-null-body.any.js` expects.

`preload/prefetch-document.html`: "different-site document prefetch with
'as=document' should not be consumed" now also fails at times, like its
two siblings. Servo has no HTTP cache partition (servo#33616), so the fresh
response of a cross-site prefetch answers the later navigation, unless
the navigation starts before the prefetch's response headers arrive and
goes to the network. With `network_http_cache_disabled=true` the subtest
passes and the "same origin ... should be consumed" sibling fails
instead.

Fork note: supersedes patches 79 and 80 (their cache code goes; their
fetch tests stay), and moves the cache side of patch 92 into
`http_cache::inflight`. 79 and 80 stayed on the stack at the 2026-10-22
sync: patch 92 builds on both (it calls 79's `may_store_media_response`
and sets 80's abort flag), so dropping them means reworking 92. Uses
`http-cache-rules` 0.1.0 from crates.io.

Testing: tests/http_cache.rs covers storability, Vary, freshness,
stale-while-revalidate with and without a client, partial entries and
ranges (with the five range tests of the `http-cache-range` branch),
the encoded body, the media storage rule, same-origin invalidation and
the most recent variant. tests/fetch.rs covers a 304 with another strong
validator, a 304 resetting Age, and a 304 with no-store.
tests/http_loader.rs covers a compressed response answered from the
cache, a compressed body cut short, and fetches that do not wait for the
headers of another fetch, a response that needs validation, a variant
of another request or a body too large to store, and that stop waiting
when cancelled or after a while; tests/http_cache.rs also a URL with
credentials and a fragment; tests/cache_store.rs an id reused by another
entry. The fetch tests of
patches 79, 80 and 92 are adapted to entries that appear on commit.

Validation: `./mach test-unit -p servo-net`: 435 tests pass. Negative controls, each run once: without the origin check, the most-recent selection, the 304 exception in `tee` or the suspended-producer wait, `test_invalidation_only_reaches_the_same_origin`, `test_the_most_recent_matching_response_is_used`, `test_a_304_for_another_response_makes_the_request_again_without_preconditions` and `test_fetch_waiting_for_a_suspended_response_uses_the_network` fail. Without the commit on the decoded end, the stamps and the waiting rule, `test_compressed_response_is_answered_from_cache`, `test_compressed_response_cut_short_is_not_stored`, `a_reused_id_is_not_touched_on_behalf_of_its_old_entry` (memory and disk store) and `test_fetch_does_not_wait_for_a_response_that_needs_validation` fail; with waiters waiting from the writer's registration on, `test_fetch_does_not_wait_for_the_headers_of_another_fetch` fails as well, and with waiters waiting for any response the validation one does. With patches 121 to 123: `./mach test-unit --profile checked-release` (1212 tests) and `--doc` pass; `./mach clippy --locked -- -- --deny warnings`, the crown `checked-release` build and the OHOS `checked-release` build with `RUSTFLAGS="-D warnings"` are clean, as is `./mach test-tidy`. WPT, `checked-release`, 8 processes, fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, cors, xhr, preload, html/semantics/embedded-content/media-elements and html/semantics/scripting-1, 2140 tests: 2134 as expected, and "Response with Cache-Control: max-age=2592000, public and Pragma: no-cache should not be cached" now passes (expectation removed; the crate's deviation D-2). The other six behave the same alone on ohos-main 091e100215c: src_object_blob.html times out 3 of 8 runs (2 of 8 there), load-removes-queued-error-event.html crashes 5 of 8 (4 of 8 there), media_fragment_seek.html fails and autoplay-default-permissions-policy.https.sub.html passes every time on both, and seek-to-max-value.htm and track-remove-by-setting-innerHTML.html pass 3 of 3 on both. Full WPT, `checked-release`, 12 processes, on the build before the waiting rule was fixed: 58273 of 58348 tests as expected. The other 75 were run again serially, those still unexpected on ohos-main 091e100215c too, and the 12 that differed 3 times alone on both: async_003.htm, async_004.htm and async_005.htm failed every time on the branch only (their script's headers are delayed, and a second fetch of it waited for them), and pass 3 of 3 with the fix; the other 9 behave the same on both. The focused set without scripting-1 on QuickJS (`--js-engine quickjs`), before the review fixes: 1540 of 1545 as expected, three of the same media tests, and two track-element timeouts that pass 3 of 3 alone on both builds. On ohos-main deaca97 with `http-cache-rules` 0.1.0 from crates.io (the same files as the path dependency tested above): `./mach test-unit -p servo-net` passes, 435 tests here and 472 with patch 121, and the CI-parity checks above pass again at patch 123, except `indexeddb::engines::sqlite::tests::test_async_operations` of servo-storage, which timed out once and passes 3 of 3 alone. `test_response_cache_status_is_validated` failed 5 of 320 runs, 32 at a time, while the commit of the first response was not waited for, and 0 of 960 after. WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, preload and html/semantics/scripting-1, 756 tests: as expected but for execution-timing/077.html, which passes 3 of 3 alone here and fails 1 of 3 alone on ohos-main 091e100215c, and the prefetch-document subtest above, which passed 2 of 3 runs alone; its expectation now allows both. Review fixes (the wait ends on cancellation, does not start for another variant or a body too large to store, and times out; the key leaves out the credentials and fragment of the URL): 440 tests pass here, and 481 with patch 121. Negative controls, each run once: without the cancellation of the wait, `test_a_waiting_fetch_stops_waiting_when_it_is_cancelled` fails; without the `Vary` check, the cap in `TeeBody`, the timeout or the password left out of the key, `test_fetch_does_not_wait_for_a_response_that_varies_from_its_request`, `test_fetch_does_not_wait_for_a_response_too_large_to_store`, `test_a_waiting_fetch_goes_to_the_network_after_a_while` and `test_url_credentials_and_fragment_are_not_part_of_the_key` fail. At patch 123 the CI-parity checks pass again (`test-unit --profile checked-release`: 1221 tests), and WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, preload, html/semantics/scripting-1 and html/semantics/embedded-content/media-elements, 1679 tests, run as expected but for four of the media tests above and seek-to-currentTime.html, which passes 3 of 3 alone on both builds. A first version also returned a network error from step 9 of HTTP-network-or-cache fetch for any fetch cancelled before it reached the network. PR CI caught that: requests sent while a document unloads were dropped, and fetch/fetch-later/send-on-discard/send-multiple, both sandbox-top-navigation-child-delivered tests, navigation-timing/nested-unload-timing and navigation-timing/prefetch-transfer-size-executor failed in both attempts of that CI run and in a serial local run. Without it they run as expected in 2 of 2 serial local runs; of the other stable unexpected results of that CI run, window-resize-event.html times out alone on ohos-main 091e100215c too, and test_resource_timing and media-loading-pseudo-classes-in-has.sub.html behave the same alone on both builds and are flaky upstream.
AI-assisted: Yes (agent session; the agent ported the storage half of the http-cache-v2 branch, wrote the glue over http-cache-rules and the merge with patches 79, 80 and 92, and wrote and ran the tests)
AI-assisted: Yes (agent session; 2026-10-22 sync -- conflict resolution: `http_cache.rs` deleted as before, which drops upstream's edits to it (servo#48927 most recent matching response and replacement of matching responses, servo#48842); this cache uses the most recent matching response already and makes the request again when a 304 is about another response. The old cache steps of HTTP-network-or-cache fetch and `block_for_cache_ready` go as before, with upstream's edits to them (servo#48927, servo#48867); `obtain_response` keeps upstream's new `FetchParams` signature (servo#49040) and returns the body below the decoder as before; test imports merged. `./mach test-unit -p servo-net` at this commit: 440 tests pass)
AI-assisted: Yes (agent session; 2026-10-22 sync -- the fork note says why patches 79 and 80 were not dropped)
AI-assisted: Yes (agent session; 2026-10-29 sync -- test compile fix: `request_with_client()` sets the new `RequestClient::network_partition_key` (servo#49252))
AI-assisted: Yes (agent session; 2026-11-09 sync -- components/net/http_cache.rs stays deleted; upstream's cleanup of it (servo#49434) has no counterpart in the new cache)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
A fetch can only be cancelled. When its player is full, a media element
cancels its fetch and later starts a new Range request. That throws away
the bytes in flight (about 2.5 MB per refill on an OpenHarmony board),
costs a new request and, on HTTP/1.1, a new connection, because a body
that is not read to its end cannot be drained. Gecko suspends the
channel instead, and Chromium defers loading.

Add FetchController::suspend and FetchController::resume. Like a
cancellation, they go through the fetch thread of the content process,
so they stay ordered after the start of the fetch, and reach the
resource thread as CoreResourceMsg::Suspend and CoreResourceMsg::Resume.
There they set the state of the request's CancellationListener, which
now keeps running, suspended or cancelled in a tokio watch channel.

The HTTP network fetch reads the body in a loop that, while the fetch
is suspended, waits for the state to change instead of polling the
body, so that TCP or HTTP/2 flow control holds back the server. Data
received before the suspension is still delivered, and after a resume
the body continues with the next byte. A cancellation wakes the loop at
once, also while it waits for data from the network; before, it was
only noticed when the next chunk arrived. If the connection fails or
closes while the fetch is suspended, the fetch ends after the resume as
an interrupted body does. The loop keeps what it did before: media
bodies are not kept, and a cancellation marks the response aborted
under the body lock.

Net bounds suspension itself, since it learns of no content process
that goes away and an unread body never sees its connection close. A
fetch that stays suspended for longer than the new pref
network_fetch_suspend_timeout_ms (60 s) ends with a network error, as
if its connection was lost. At most two fetches per origin are
suspended at once in each HTTP state, and a further suspension is
ignored: the fetches to an origin share an HTTP/2 connection, and every
suspended stream holds its stream window of the connection window, 2 of
5 MiB with hyper's defaults, so three would stall every other request
to the origin. A suspended fetch that is redirected moves to the new
origin, or is resumed if that has no place left. Suspension is advisory
and only takes effect while a body is read from the network: cache
hits, which are delivered in one chunk, data, file, blob and protocol
handler responses, and fetches that ended ignore it.

A fetch that waits in the HTTP cache for a body that another fetch is
still receiving treats a suspension of that fetch like an abort, and
goes to the network instead of waiting for the resume.

The responses of the redirects, authentication retries and CORS
preflight of a fetch share its listener, so while it is suspended, the
unread bodies of such responses hold their connection until the resume
or the deadline instead of being drained.

Fork note: meant for upstream. Drop once upstream has it.

Testing: unit tests with servers that stream a 64 MiB body and count
what they hand to the connection: a suspended fetch holds back the
server and receives the whole body intact after the resume, over
HTTP/1.1 and over HTTP/2 (TLS with ALPN, a new test server); a
cancellation ends a suspended fetch, and one that waits for a stalled
server, within a second; a fetch whose server closes the connection
while it is suspended ends after the resume with what was sent; the
deadline ends suspended fetches with a network error and frees their
places; a third suspension per origin is ignored and its server keeps
sending; fetches waiting in the HTTP cache for a suspended response go
to the network; FetchController suspends and resumes a fetch through
the fetch thread and the resource thread, and does nothing after the
end.

Folded in "net: Report whether a fetch was suspended":

Net ignores a suspension when it does not read the body from the
network (a cache hit, another scheme, or after the end) and when two
fetches to the origin of the request are suspended already, and nothing
told the consumer. A media element that suspended its fetch then kept
queueing a body that kept arriving, up to its 32 MiB cap, which it
discarded to restart the fetch, while its networkState said the
download was suspended.

Let the suspension carry an optional GenericCallback, to which the
resource thread sends the result of CancellationListener::suspend: true
if the fetch is suspended now, false if the suspension was ignored. A
GenericCallback works in both single-process and multi-process mode,
and runs in the process that suspended the fetch, so the consumer can
queue a task from it.

Fork note: meant for upstream. Drop once upstream has it.

Testing: a unit test suspends three fetches to one origin through
FetchController and the resource thread: the first two are reported as
suspended and the third not, and a suspension after the end of a fetch
is reported as ignored.

Validation: `./mach test-unit -p servo-net`: 412 tests pass (403 before), also with the suspension tests in one process. While a fetch was suspended, the server handed 4.9 MiB of a 64 MiB body to the connection over HTTP/1.1 and 2.1 MiB over HTTP/2. `./mach test-wpt --release --processes 6 --timeout-multiplier 2` fetch/api/basic fetch/api/abort fetch/range fetch/http-cache xhr html/semantics/embedded-content/media-elements: 1034 tests, 1027 as expected; the other seven behave the same with the parent commit when run alone three times.
Validation: ("net: Report whether a fetch was suspended") `./mach test-unit -p servo-net`: 413 tests pass (412 before); the new test passed five runs in a row, and fails when the resource thread always reports a suspension. `./mach check --ohos` passes.
AI-assisted: Yes (agent session; implemented, tested and measured by the agent, reworked after a review by another agent)
AI-assisted: Yes (agent session; 2026-10-22 sync -- merged with upstream servo#49049 (fetch-thread `Cancel` with `forget`, `cancel_and_forget_async_fetch`) and servo#49040 (timing info in the fetch params): `Suspend` and `Resume` sit next to the new `Cancel` variant, the imports are joined, and the body loop takes its timing from `fetch_params.timing_info`. `./mach test-unit -p servo-net` at this commit: 412 tests pass)
AI-assisted: Yes (agent session; "net: Report whether a fetch was suspended": implemented and tested by the agent)
AI-assisted: Yes (agent session; "net: Report whether a fetch was suspended": 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `Suspend` reply next to upstream's `Cancel` struct variant (servo#49049))
AI-assisted: Yes (agent session; 2026-11-09 restack -- folded in "net: Report whether a fetch was suspended", which tells the consumer when net ignores a suspension of this patch's API)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
The HTTP cache kept every stored body as a `Vec<u8>` in the net process,
shared with the response handed to the consumer, so net also kept the
decoded body of every response until its fetch ended. Its RFC 9111
rules were hand-written for RFC 7234.

The rules now come from the `http-cache-rules` crate: storability, the
stored and updated header fields, freshness (with `max-age`, `Expires`,
the heuristic, `Age` and `Date`), `Vary`, `stale-while-revalidate`,
`immutable`, the request directives, the validation request and the
merge of a 304. The crate decides and stores nothing; its requirements
are traced to the RFC text and tested, model checked and fuzzed in its
own repository. `http_cache::policy` configures it as a private cache
that stores 206 responses and their bodies encoded.

Servo keeps what belongs to the fetch layer: the cache modes, background
revalidation (only for requests with a client), invalidation after
unsafe methods, ranges, and its own refusals on top of the crate: `Vary:
*`, entries over the store's size limit, 206 without `Content-Range`,
and the storage rule for audio and video of patch 79.

Storage moves behind `CacheStore`, which streams bodies in and out:

  * `TeeBody` copies each frame into the store below the content
    decoder, so the stored body is what came off the wire, and the copy
    is a reference count, not a second allocation. The store's bounded
    queue back-pressures the network.
  * A hit streams the entry through the decoder in chunks.
  * `ResponseBody::Streamed` marks a body delivered to the consumer and
    kept nowhere. Only subresource integrity and preloads still keep the
    whole decoded body (`retains_whole_body`), so net no longer keeps
    media bodies, which patch 79 had to arrange separately.
  * An entry is visible only once its decoded body ended cleanly, so a
    failed, cancelled or truncated body never becomes an entry, which
    patch 80 had to arrange separately. The fetch commits it through a
    `TeeCommit`, not `TeeBody` at the end of the network body: the
    decoder stops reading at the end of a gzip or brotli stream.
  * Every entry carries a random stamp, and the store opens, updates
    and removes an entry only for the stamp it was looked up with, since
    a later entry of the key may reuse its id.
  * `http_cache::inflight` lets one fetch write a key. Once its headers
    show a fresh response, others wait for it and read the committed
    entry, or go to the network if it aborts or, as patch 92 requires,
    while it is suspended. Before that, or if the response needs
    validation, they go to the network as with the old cache, so a slow
    or long-polled response holds up no other fetch. Once the whole body
    has arrived, they wait for any response while the store commits it,
    so a fetch right after another one finds its entry. A fetch does
    not wait for a response that varies on a field in which its own
    request differs, or whose body outgrows what the store accepts. It
    stops waiting when it is cancelled, and goes on from there like any
    cancelled fetch, and it waits 5 s at most.
  * `MemoryStore` is the only store in this patch: byte-bounded, LRU,
    for private browsing, temporary storage, no cache directory, and
    the tests. The SQLite cache goes, and `rusqlite`, `sea-query` and
    `quick_cache` leave `components/net`.

Fixes over the cache of the `http-cache-v2` branch, which this replaces:
a 304 no longer collapses repeated stored fields (a two-line CSP lost a
line) nor freshens on a weak or mismatching strong validator, `Age`
takes `Date` and the request time into account, the RFC 850 and asctime
date formats are understood, and `Vary` compares all field lines. That
branch also never stored a compressed response but stored a gzip body
cut short under clean framing, let a late 304 freshen or remove the
entry that had replaced its own, and made a fetch wait for the whole
body of another fetch's response even when it could not use it, and
wrote the URL's credentials into every entry: the key now leaves them
and the fragment out, and a stored response is served with the
request's URL. An
invalidation through `Location` or `Content-Location` reaches only URIs
of the target's origin (RFC 9111 4.4). Of several matching stored
responses the most recent is used (RFC 9111 4). When a 304 is about
another response than the stored one, the request is made again without
preconditions, and that response is stored.

Prefs: `network_http_cache_size` (an entry count) and
`network_http_disk_cache` (a path) are replaced by
`network_http_memory_cache_size` and `network_http_cache_max_entry_size`,
in bytes; `network_http_disk_cache_size` gains 0 = automatic.

`apply_algorithm_to_response` returned through `unreachable!()` when
the body was not `Done`, which a null body status makes it, and a
streamed body would reach reliably. It now returns a digest that cannot
match, so the fetch fails as `response-null-body.any.js` expects.

`preload/prefetch-document.html`: "different-site document prefetch with
'as=document' should not be consumed" now also fails at times, like its
two siblings. Servo has no HTTP cache partition (servo#33616), so the fresh
response of a cross-site prefetch answers the later navigation, unless
the navigation starts before the prefetch's response headers arrive and
goes to the network. With `network_http_cache_disabled=true` the subtest
passes and the "same origin ... should be consumed" sibling fails
instead.

Fork note: supersedes patches 79 and 80 (their cache code goes; their
fetch tests stay), and moves the cache side of patch 92 into
`http_cache::inflight`. 79 and 80 stayed on the stack at the 2026-10-22
sync: patch 92 builds on both (it calls 79's `may_store_media_response`
and sets 80's abort flag), so dropping them means reworking 92. Uses
`http-cache-rules` 0.1.0 from crates.io.

Testing: tests/http_cache.rs covers storability, Vary, freshness,
stale-while-revalidate with and without a client, partial entries and
ranges (with the five range tests of the `http-cache-range` branch),
the encoded body, the media storage rule, same-origin invalidation and
the most recent variant. tests/fetch.rs covers a 304 with another strong
validator, a 304 resetting Age, and a 304 with no-store.
tests/http_loader.rs covers a compressed response answered from the
cache, a compressed body cut short, and fetches that do not wait for the
headers of another fetch, a response that needs validation, a variant
of another request or a body too large to store, and that stop waiting
when cancelled or after a while; tests/http_cache.rs also a URL with
credentials and a fragment; tests/cache_store.rs an id reused by another
entry. The fetch tests of
patches 79, 80 and 92 are adapted to entries that appear on commit.

Validation: `./mach test-unit -p servo-net`: 435 tests pass. Negative controls, each run once: without the origin check, the most-recent selection, the 304 exception in `tee` or the suspended-producer wait, `test_invalidation_only_reaches_the_same_origin`, `test_the_most_recent_matching_response_is_used`, `test_a_304_for_another_response_makes_the_request_again_without_preconditions` and `test_fetch_waiting_for_a_suspended_response_uses_the_network` fail. Without the commit on the decoded end, the stamps and the waiting rule, `test_compressed_response_is_answered_from_cache`, `test_compressed_response_cut_short_is_not_stored`, `a_reused_id_is_not_touched_on_behalf_of_its_old_entry` (memory and disk store) and `test_fetch_does_not_wait_for_a_response_that_needs_validation` fail; with waiters waiting from the writer's registration on, `test_fetch_does_not_wait_for_the_headers_of_another_fetch` fails as well, and with waiters waiting for any response the validation one does. With patches 121 to 123: `./mach test-unit --profile checked-release` (1212 tests) and `--doc` pass; `./mach clippy --locked -- -- --deny warnings`, the crown `checked-release` build and the OHOS `checked-release` build with `RUSTFLAGS="-D warnings"` are clean, as is `./mach test-tidy`. WPT, `checked-release`, 8 processes, fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, cors, xhr, preload, html/semantics/embedded-content/media-elements and html/semantics/scripting-1, 2140 tests: 2134 as expected, and "Response with Cache-Control: max-age=2592000, public and Pragma: no-cache should not be cached" now passes (expectation removed; the crate's deviation D-2). The other six behave the same alone on ohos-main 091e100215c: src_object_blob.html times out 3 of 8 runs (2 of 8 there), load-removes-queued-error-event.html crashes 5 of 8 (4 of 8 there), media_fragment_seek.html fails and autoplay-default-permissions-policy.https.sub.html passes every time on both, and seek-to-max-value.htm and track-remove-by-setting-innerHTML.html pass 3 of 3 on both. Full WPT, `checked-release`, 12 processes, on the build before the waiting rule was fixed: 58273 of 58348 tests as expected. The other 75 were run again serially, those still unexpected on ohos-main 091e100215c too, and the 12 that differed 3 times alone on both: async_003.htm, async_004.htm and async_005.htm failed every time on the branch only (their script's headers are delayed, and a second fetch of it waited for them), and pass 3 of 3 with the fix; the other 9 behave the same on both. The focused set without scripting-1 on QuickJS (`--js-engine quickjs`), before the review fixes: 1540 of 1545 as expected, three of the same media tests, and two track-element timeouts that pass 3 of 3 alone on both builds. On ohos-main deaca97 with `http-cache-rules` 0.1.0 from crates.io (the same files as the path dependency tested above): `./mach test-unit -p servo-net` passes, 435 tests here and 472 with patch 121, and the CI-parity checks above pass again at patch 123, except `indexeddb::engines::sqlite::tests::test_async_operations` of servo-storage, which timed out once and passes 3 of 3 alone. `test_response_cache_status_is_validated` failed 5 of 320 runs, 32 at a time, while the commit of the first response was not waited for, and 0 of 960 after. WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, preload and html/semantics/scripting-1, 756 tests: as expected but for execution-timing/077.html, which passes 3 of 3 alone here and fails 1 of 3 alone on ohos-main 091e100215c, and the prefetch-document subtest above, which passed 2 of 3 runs alone; its expectation now allows both. Review fixes (the wait ends on cancellation, does not start for another variant or a body too large to store, and times out; the key leaves out the credentials and fragment of the URL): 440 tests pass here, and 481 with patch 121. Negative controls, each run once: without the cancellation of the wait, `test_a_waiting_fetch_stops_waiting_when_it_is_cancelled` fails; without the `Vary` check, the cap in `TeeBody`, the timeout or the password left out of the key, `test_fetch_does_not_wait_for_a_response_that_varies_from_its_request`, `test_fetch_does_not_wait_for_a_response_too_large_to_store`, `test_a_waiting_fetch_goes_to_the_network_after_a_while` and `test_url_credentials_and_fragment_are_not_part_of_the_key` fail. At patch 123 the CI-parity checks pass again (`test-unit --profile checked-release`: 1221 tests), and WPT fetch/http-cache, fetch/range, fetch/stale-while-revalidate, fetch/api, preload, html/semantics/scripting-1 and html/semantics/embedded-content/media-elements, 1679 tests, run as expected but for four of the media tests above and seek-to-currentTime.html, which passes 3 of 3 alone on both builds. A first version also returned a network error from step 9 of HTTP-network-or-cache fetch for any fetch cancelled before it reached the network. PR CI caught that: requests sent while a document unloads were dropped, and fetch/fetch-later/send-on-discard/send-multiple, both sandbox-top-navigation-child-delivered tests, navigation-timing/nested-unload-timing and navigation-timing/prefetch-transfer-size-executor failed in both attempts of that CI run and in a serial local run. Without it they run as expected in 2 of 2 serial local runs; of the other stable unexpected results of that CI run, window-resize-event.html times out alone on ohos-main 091e100215c too, and test_resource_timing and media-loading-pseudo-classes-in-has.sub.html behave the same alone on both builds and are flaky upstream.
AI-assisted: Yes (agent session; the agent ported the storage half of the http-cache-v2 branch, wrote the glue over http-cache-rules and the merge with patches 79, 80 and 92, and wrote and ran the tests)
AI-assisted: Yes (agent session; 2026-10-22 sync -- conflict resolution: `http_cache.rs` deleted as before, which drops upstream's edits to it (servo#48927 most recent matching response and replacement of matching responses, servo#48842); this cache uses the most recent matching response already and makes the request again when a 304 is about another response. The old cache steps of HTTP-network-or-cache fetch and `block_for_cache_ready` go as before, with upstream's edits to them (servo#48927, servo#48867); `obtain_response` keeps upstream's new `FetchParams` signature (servo#49040) and returns the body below the decoder as before; test imports merged. `./mach test-unit -p servo-net` at this commit: 440 tests pass)
AI-assisted: Yes (agent session; 2026-10-22 sync -- the fork note says why patches 79 and 80 were not dropped)
AI-assisted: Yes (agent session; 2026-10-29 sync -- test compile fix: `request_with_client()` sets the new `RequestClient::network_partition_key` (servo#49252))
AI-assisted: Yes (agent session; 2026-11-09 sync -- components/net/http_cache.rs stays deleted; upstream's cleanup of it (servo#49434) has no counterpart in the new cache)
Signed-off-by: Jonathan Schwender <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants