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
base: main
Are you sure you want to change the base?
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? |
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: