qri-io / qri

you're invited to a data party!
https://qri.io
GNU General Public License v3.0
1.1k stars 66 forks source link

fix(websocket): request context causes early cancellation #1926

Closed ramfox closed 2 years ago

ramfox commented 2 years ago

Using the http request context as the context for read causes the connection to close early. The examples used in the nhooyr/websocket repo do not cause this issue, so not totally sure what the error is here. However, in order to have the context survive, we need to use the background context. Thankfully, if the connection closes we are able to catch it in the read function. It will error and we can prune the connection. This will have to do until we can devote more time to understand what is going wrong.