Skip to content

Commit

Permalink
try block_on instead of now_or_never in the http middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Dec 20, 2024
1 parent 84bcf25 commit f58ee2e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions zebra-rpc/src/server/http_request_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ where
// Fix the request body
let request = request.map(|body| {
let new_body = tokio::task::block_in_place(|| {
let bytes = body
.collect()
.map(|data| data.expect("Failed to collect body data").to_bytes())
.now_or_never()
.expect("Failed to get body data immediately");
let bytes = tokio::runtime::Handle::current().block_on(async {
body.collect()
.await
.expect("Failed to collect body data")
.to_bytes()
});
let data = String::from_utf8_lossy(bytes.as_ref()).to_string();

// Fix JSON-RPC 1.0 requests.
Expand Down

0 comments on commit f58ee2e

Please sign in to comment.