Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: don't share reqwest::HttpClient across tokio runtimes #24092

Merged
merged 7 commits into from
Jun 3, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jun 3, 2024

This also fixes several issues where we weren't properly creating http clients with the user's settings.

@dsherret dsherret marked this pull request as ready for review June 3, 2024 20:08
@@ -641,140 +634,17 @@ impl FileFetcher {
}
}

#[derive(Debug, Eq, PartialEq)]
enum FetchOnceResult {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to HttpClient so that more of the reqwest api usage is buried in there.

}
}

#[allow(clippy::print_stdout)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The below is mostly copy/paste from file_fetcher.rs

@@ -407,14 +518,67 @@ pub async fn get_response_body_with_progress(
Ok(bytes.into())
}

/// Construct the next uri based on base uri and location header fragment
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy+pste from file_fetcher.rs

// If there's an absolute url with no path, eg. https://my-cli.com
// perform a request, and see if it redirects another file instead.
let mut url = url.clone();

if url.path() == "/" {
let client = HttpClient::new(None, None);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug. This was not taking into account the user's configuration.

@@ -672,9 +682,8 @@ async fn testify(
},
};

let client = Client::new();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug.

bail!("No OIDC token available");
};

let client = Client::new();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug.

@dsherret dsherret requested a review from bartlomieju June 3, 2024 20:17
@dsherret dsherret changed the title refactor: don't share rewest::HttpClient across tokio runtimes refactor: don't share reqwest::HttpClient across tokio runtimes Jun 3, 2024
cli/clippy.toml Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking

cli/http_util.rs Outdated Show resolved Hide resolved
@bartlomieju
Copy link
Member

I'm a bit wary about all these clones, but let's see if we see any regression in the benchmarks.

@dsherret
Copy link
Member Author

dsherret commented Jun 3, 2024

I'm a bit wary about all these clones, but let's see if we see any regression in the benchmarks.

Should be fine. It's only cloning Arcs and mostly only when making http requests (reqwest::HttpClient contains an Arc).

@dsherret dsherret enabled auto-merge (squash) June 3, 2024 20:46
@dsherret dsherret merged commit 3341c50 into denoland:main Jun 3, 2024
17 checks passed
@dsherret dsherret deleted the http_client_more_rc branch June 4, 2024 03:30
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.

None yet

2 participants