hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Consider removing "dispatch dropped without returning error"

Open nox opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. Hyper panics with "dispatch dropped without returning error" if the background dispatch task goes away, either because the runtime was dropped or some user-provided code such as a HttpBody implementation panicked

Describe the solution you'd like Hyper should catch the panic and return a proper error instead of panicking with "dispatch dropped without returning error".

Cc @seanmonstar

nox avatar Sep 16 '21 08:09 nox

Yea, we can do better. We probably can't completely remove the panic, since the Canceled error is part of the oneshot contract. But we can improve two the existing cases that can happen, to try to eliminate it so that panic never can happen.

  • The runtime is dropped, killing the dispatch task.
  • The dispatch task panics, due to user code.

We can add a Guard to the oneshot::Sender (Callback) to make it send an appropriate hyper::Error in drop, if not consumed. If std::thread::panicking(), then we can send an error about the dispatch task having panicked. If not, we can send an error about an unexpected runtime dropping the task.

seanmonstar avatar Sep 16 '21 17:09 seanmonstar

I'm seeing this panic in real code, it would be nice to avoid it somehow. Not sure how it happens. image

jyn514 avatar Feb 07 '22 15:02 jyn514