rust-dl-webserver
rust-dl-webserver copied to clipboard
crashes
Hi Getting crashes with this message:
thread '<unnamed>' panicked at 'Channel from calling thread disconnected: "SendError(..)"'
specifically:
let batch_output = handler(batch_input $(, &context.$ctx_arg )*);
for (output, mut result_tx) in batch_output.into_iter().zip(batch_txs) {
result_tx.send(output).expect("Channel from calling thread disconnected");
}
Seems if the client end disconnects / hangs etc. this will cause the server to crash (batched_fn
channel)
Hey @avnerbarr, are you able to reproduce this consistently? If so, how? I'd like to try.
Hi @epwalsh
The way I would suggest is to create a toy project (I ran in debug) which calls out to the server and kill the process before the server is able to respond.
Very trivial example I tried which seems to do the trick (most times):
async fn call_server(&self, text: &str) {
let mut req = Request::from(text.to_string());
let client = Self::builder();
let p = client.json(&req);
let a = p.timeout(std::time::Duration::from_secs(3)).send().await?;
a.json::<Response>()
.await
.map_err(|error| {
Self::report_error(&error);
CloudError::from(error)
})
}
fn builder() -> RequestBuilder {
reqwest::Client::new().post(format!(
"{}://{}:{}/generate",
Self::protocol(),
Self::host(),
Self::port()
)) // stubbed
}
The server is per the code example, but perhaps tweak the batch size and batch time to allow easier debugging