Option to read response body even if context is canceled? #128
-
Hey Folks! Maybe this is already supported and I just can't figure out how to do it but we'd like to read the response body even in the case that the request context is canceled. Use case is as such: We're building a query API which will often be running long queries. We'd like to be able to deserialize the response body even in the event of request cancelation, and not just receive the cancelation error. The response body will have the queryID that was canceled which is useful in reporting status back to the UI. It appears that this is not possible digging into the Lines 16 to 20 in 02ba493
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If the context is cancelled, the body will either be truncated or nil, no? |
Beta Was this translation helpful? Give feedback.
-
Oh dear, the issue is below this library. 😅 Sorry about that! Could have sworn I'd done this before with the standard library but just wrote a test to verify I myself was hallucinating. Nevermind me then! Thanks for the amazing library! FWIW for those coming here later, it's possible on the server side to catch the request cancelation and write a different response. Apparently that's not the case on the client side. I'll search the go issues to see if there's any interest in this. |
Beta Was this translation helpful? Give feedback.
Oh dear, the issue is below this library. 😅 Sorry about that! Could have sworn I'd done this before with the standard library but just wrote a test to verify I myself was hallucinating.
Nevermind me then! Thanks for the amazing library!
FWIW for those coming here later, it's possible on the server side to catch the request cancelation and write a different response. Apparently that's not the case on the client side. I'll search the go issues to see if there's any interest in this.