Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/rust-miri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const MIRI_CRATES = [
"bun_clap",
"bun_dispatch",
"bun_errno",
"bun_http",
"bun_http_types",
"bun_md",
"bun_pod",
Expand Down
28 changes: 2 additions & 26 deletions src/http/AsyncHTTP.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use bun_threading::thread_pool::{self, Batch, Task};
use bun_url::{PercentEncoding, URL};

use bun_dotenv::Loader as DotEnvLoader;
use bun_picohttp as picohttp;

use crate::headers::{self, Headers};
use crate::{
Expand All @@ -28,7 +27,6 @@ bun_core::declare_scope!(AsyncHTTP, visible);
// Intrusive fields (`real`, `next`) are raw pointers and thus lifetime-erased;
// the HTTP-thread copy uses the same `'a` as the JS-thread original it mirrors.
pub struct AsyncHTTP<'a> {
pub response: Option<picohttp::Response<'static>>,
pub request_headers: headers::EntryList,
pub request_body: HTTPRequestBody<'a>,
pub(crate) method: Method,
Expand Down Expand Up @@ -306,23 +304,18 @@ impl<'a> AsyncHTTP<'a> {
/// Copy HTTP-thread progress state into the JS-thread "real" instance.
///
/// Copy exactly the fields the JS side observes between progress
/// callbacks: the post-redirect `url`, response/timing fields written by
/// callbacks: the post-redirect `url`, the error and timing fields written by
/// `on_async_http_callback`, and the `client` flags/counters used for
/// shutdown decisions and error formatting. Owned allocations stay with
/// `src` (the HTTP-thread copy keeps running while `has_more`).
pub fn sync_progress_from(&mut self, src: &AsyncHTTP<'a>) {
self.url = src.url.clone();
self.elapsed = src.elapsed;
self.err = src.err;
self.response = src.response;
self.client.url = src.client.url.clone();
self.client.flags = src.client.flags;
self.client.remaining_redirect_count = src.client.remaining_redirect_count;
}

pub fn clear_data(&mut self) {
self.response = None;
}
}

// ──────────────────────────────────────────────────────────────────────────
Expand All @@ -342,11 +335,6 @@ impl Preconnect {
// SAFETY: `this` was produced by `heap::alloc` in `preconnect()` and is
// uniquely owned here; `async_http` was fully written before scheduling.
unsafe {
(*this)
.async_http
.as_mut()
.expect("Preconnect.async_http set in preconnect()")
.clear_data();
if (*this).is_url_owned {
// SAFETY: `is_url_owned` is the caller's promise that `url.href`
// is a global-allocator `Box<[u8]>` we now own.
Expand Down Expand Up @@ -447,7 +435,6 @@ impl<'a> AsyncHTTP<'a> {
);

let mut this = AsyncHTTP {
response: None,
request_headers: headers,
request_body: HTTPRequestBody::Bytes(request_body),
method,
Expand Down Expand Up @@ -602,9 +589,6 @@ fn send_sync_callback(
if let Some(mut real) = async_http.real {
// SAFETY: `real` outlives the HTTP-thread copy by construction.
let real = unsafe { real.as_mut() };
// `response` aliases the metadata `send_sync` hands to the caller; a
// stored copy would dangle once that metadata is dropped.
real.response = None;
real.err = async_http.err;
real.elapsed = async_http.elapsed;
}
Expand Down Expand Up @@ -684,15 +668,7 @@ impl<'a> AsyncHTTP<'a> {
let callback = (*this).result_callback;
(*this).elapsed = http_thread_timer_read().saturating_sub((*this).elapsed);

if result.is_success() {
(*this).err = None;
if let Some(metadata) = &result.metadata {
(*this).response = Some(metadata.response);
}
} else {
(*this).err = result.fail;
(*this).response = None;
}
(*this).err = result.fail;

// Log the tracker count, then shrink
// the abort tracker back down once it has drained from a
Expand Down
Loading
Loading