mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Don't drop the request sender before we finish reading the response
It *looks like* hyper will drop the connection once its request sender is dropped, regardless of if the last request hasn't had its response completed. This attempts to resolve some spurious connection errors.
This commit is contained in:
parent
360b264a0f
commit
deecd77aec
1 changed files with 4 additions and 2 deletions
|
@ -113,7 +113,6 @@ impl HttpRpc {
|
|||
.await
|
||||
.map_err(|e| RpcError::ConnectionError(e.to_string()))?;
|
||||
let connection_task = tokio::spawn(connection);
|
||||
connection_task_handle = Some(connection_task.abort_handle());
|
||||
|
||||
let mut response = requester
|
||||
.send_request(request("/".to_string() + route))
|
||||
|
@ -151,6 +150,9 @@ impl HttpRpc {
|
|||
.send_request(request)
|
||||
.await
|
||||
.map_err(|e| RpcError::ConnectionError(e.to_string()))?;
|
||||
|
||||
// Also embed the requester so it's not dropped, causing the connection to close
|
||||
connection_task_handle = Some((requester, connection_task.abort_handle()));
|
||||
}
|
||||
|
||||
response
|
||||
|
@ -184,7 +186,7 @@ impl HttpRpc {
|
|||
.map_err(|e| RpcError::ConnectionError(e.to_string()))?
|
||||
.to_vec();
|
||||
|
||||
if let Some(connection_task) = connection_task_handle {
|
||||
if let Some((_, connection_task)) = connection_task_handle {
|
||||
// Clean up the connection task
|
||||
connection_task.abort();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue