-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat(ext/fetch): Replace reqwest with reqwest_middleware #23539
Conversation
) -> Result<(), AnyError> { | ||
HTTP_MIDDLEWARE | ||
.lock() | ||
.map_err(|_e| generic_error("cannot acquire poisoned lock"))? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to handle this error? I tried e.into()
but could not figure out the compiler error.
@@ -126,7 +126,7 @@ impl<P: RemoteDbHandlerPermissions + 'static> DatabaseHandler | |||
}; | |||
|
|||
let options = &self.http_options; | |||
let client = create_http_client( | |||
let client = create_http_client_without_middleware( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're missing kv middleware. I keep reqwest::Client
here since denokv_remote
wants one.
Ah, the testing is tricky because I am using a global variable and the tokio tests are run async so the middleware is picked up by something else. Maybe there is a way to lock a specific test so I can ensure I have cleaned up? |
@maxmcd as we discussed previously on Discord, we moved away from using I'm happy to add a "hook" function that allows to customize execution of the HTTP client, but I think we need to take a fresh stab at it. Is it something we could do using |
@bartlomieju nice, yes it does seem like I could hook into that. We deprioritized this a bit for now since we're planning on getting module tracing by sticking metadata into auth tokens. Maybe best to close this for now and I'll check out |
Related to: #23516
This replaces uses of
reqwest
andreqwest::Client
with therequest_middleware
alternatives so that middleware can be mounted. The intention is to allow tracing and other middleware to be added in Rust code.I considered adding the middleware configuration to
CreateHttpClientOptions
, but it was a little tricky to plumb it through everywhere. Hopefully this use ofonce_cell
is considered ok and fits well with the contract of this middleware, ie: "add middleware to all deno http requests".Example of use: