Repository navigation
Description
During network fetch, the net crate will accumulate the entire response body. This is typically shared by way of Arc<Mutex<...>>. By retaining arbitrarily large response bodies we open up to the consequences of running out of free memory. This is less of a thorough investigation and more of a pattern that I have been noticing.
This is the part that accumulates the response during network fetch:
servo/components/net/http_loader.rs
Lines 2387 to 2403 in bfcbea9
| response_stream | |
| .into_body() | |
| .try_fold(response_body, move |response_body_accumulator, chunk| { | |
| if cancellation_listener.cancelled() { | |
| *response_body_accumulator.lock() = ResponseBody::Done(vec![]); | |
| let _ = done_sender.send(Data::Cancelled); | |
| return future::ready(Err(std::io::Error::new( | |
| std::io::ErrorKind::Interrupted, | |
| "Fetch aborted", | |
| ))); | |
| } | |
| if let ResponseBody::Receiving(ref mut body) = *response_body_accumulator.lock() { | |
| body.extend_from_slice(&chunk); | |
| let _ = done_sender.send(Data::Payload(chunk)); | |
| } | |
| future::ready(Ok(response_body_accumulator)) | |
| }) |
Below are the parts that I think we need to rein in somehow. Potential ways could be to buffer data to disk, imposing size limits, as well as dropping excess data. This list might not be exhaustive.
- The http cache
- Subresource integrity (SRI)
- devtools: limit size of response bodies sent to the network tab #48909 (slightly different mechanism)
- Tangentially:
[load_whole_resource](https://github.com/servo/servo/blob/bfcbea95680e541a7bd84d3064ac67814d7cb825/components/script/fetch/fetch.rs#L802)inscript
Additionally, there is the related issue of adding backpressure to fetch targets when bytes are potentially processed slower than they are provided by fetching:
Activity
Lemeri123 commentedon Oct 14, 2026
I am willing to work on this
freyacodes commentedon Oct 16, 2026
Hi @Lemeri123
This is a tracking issue, and not a discrete task that someone could pick up. I suppose you could tackle one of the loosely described tasks, but i would recommend against that for a first issue.
You might be interested in this guide for finding things to work on: https://book.servo.org/contributing/finding-things-to-do.html