Skip to content

How to abort a spawned task if the request is cancelled? #2931

Answered by robjtede
mkb137 asked this question in Q&A
Discussion options

You must be logged in to vote

In the original code sample, if the client disconnects then sending chunks to the channel will fail since the receiver side has been dropped. That's how you "detect" this case.

The same is true for what I'd recommend, which is the channel or writer helpers from actix_web_lab.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@mkb137
Comment options

@bublikOff
Comment options

@robjtede
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants