fix: panic in request body streaming (#11191)

This commit is contained in:
Luca Casonato 2021-06-30 18:05:58 +02:00 committed by GitHub
parent 3e21ffc935
commit de6e44794b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -356,7 +356,9 @@ pub async fn op_fetch_request_write(
.ok_or_else(bad_resource_id)?;
let body = RcRef::map(&resource, |r| &r.body).borrow_mut().await;
let cancel = RcRef::map(resource, |r| &r.cancel);
body.send(Ok(buf)).or_cancel(cancel).await??;
body.send(Ok(buf)).or_cancel(cancel).await?.map_err(|_| {
type_error("request body receiver not connected (request closed)")
})?;
Ok(())
}