mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-10-10 22:38:44 +02:00
fix(http): release the request's resources once fetch_send settles (#3669)
This commit is contained in:
1 parent
2a9c29e004
commit
b443d6be52
2 files changed
+17
-6
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"http": patch
|
||||
"http-js": patch
|
||||
---
|
||||
|
||||
`fetch_send` now releases the request's resources once the send settles. Before, a request that got a response or failed to send left its `FetchRequest` and abort sender in the webview's resource table until the webview was destroyed, so a long-lived app grew with every request.
|
||||
@@ -438,14 +438,19 @@ pub async fn fetch_send<R: Runtime>(
|
||||
let mut fut = req.fut.lock().await;
|
||||
|
||||
let res = tokio::select! {
|
||||
res = fut.as_mut() => res?,
|
||||
_ = abort_rx.0 => {
|
||||
let mut resources_table = webview.resources_table();
|
||||
resources_table.close(rid)?;
|
||||
return Err(Error::RequestCanceled);
|
||||
}
|
||||
res = fut.as_mut() => res,
|
||||
_ = abort_rx.0 => Err(Error::RequestCanceled),
|
||||
};
|
||||
|
||||
// Release resources
|
||||
{
|
||||
let mut resources_table = webview.resources_table();
|
||||
let _ = resources_table.take::<AbortSender>(req.abort_tx_rid);
|
||||
let _ = resources_table.close(rid);
|
||||
}
|
||||
|
||||
let res = res?;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::trace!("{:?}", res);
|
||||
|
||||
|
||||
Reference in new issue
Block a user