Skip to content

Commit

Permalink
fix: remove unnecesary channel when calling reqwest
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel committed Jul 4, 2023
1 parent 5c13055 commit 1f85f38
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions crates/worker/src/bindings/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use reqwest::Method;
use tokio::{runtime::Builder, sync::oneshot};
use tokio::runtime::Builder;

// Implement the HTTP bindings for the workers.
wit_bindgen_wasmtime::export!({paths: ["../../wit/core/http.wit"]});
Expand Down Expand Up @@ -36,9 +36,6 @@ impl Http for HttpBindings {
&mut self,
req: HttpRequest<'_>,
) -> Result<HttpResponse, HttpRequestError> {
// Receive the response
let (tx, mut rx) = oneshot::channel();

// Create local variables from the request
let mut headers = Vec::new();
let uri = req.uri.to_string();
Expand Down Expand Up @@ -102,23 +99,15 @@ impl Http for HttpBindings {
}
};

tx.send(response)
.expect("There was an error sending the data back to the main thread.")
});
response
})
})
.join();

match thread_result {
Ok(_) => match rx.try_recv() {
Ok(res) => match res {
Ok(res) => Ok(res),
Err(err) => Err(err),
},
Err(_) => Err(HttpRequestError {
error: HttpError::InternalError,
message: "There was an error processing the request on the host side."
.to_string(),
}),
Ok(res) => match res {
Ok(res) => Ok(res),
Err(err) => Err(err),
},
Err(_) => Err(HttpRequestError {
error: HttpError::InternalError,
Expand Down

0 comments on commit 1f85f38

Please sign in to comment.