How to capture errors caused by clients disconnecting? #2817
Unanswered
lithbitren
asked this question in
Q&A
Replies: 1 comment 4 replies
-
You'll want to use a drop guard that does the decrement on drop. Note that there are is no async drop so if you need to do something more complicated, you might have a cleanup task and just notify it from the drop guard about new cleanup work. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
In the context of Axum, if a client terminates the TCP connection while an asynchronous operation is awaiting, how can I catch this error to facilitate handling such interrupted handlers gracefully?
Consider the following handler snippet as an example:
During testing with reqwest, if I forcefully terminate the client using ctrl+c, the subsequent operations in the server-side handler are abandoned. I'm looking to capture an error in these situations to properly manage resources or clean up after such client disconnections.
axum version
axum = "0.7.5"
Beta Was this translation helpful? Give feedback.
All reactions