Closed brocaar closed 3 years ago
@tmc could you review this change?
@brocaar This looks like a good change -- do you think you could get a test case in place to demonstrate/exercise this?
Hey everyone, just stumbled into the same problem and can confirm that this changes is the cure ! It can be tested quite easily by building a grpc stream that will not close itself and then connecting with a ws client. By monitoring the goroutine counter during a disconnect of the ws client you can clearly see the serve function not getting canceled and creating a leak. Passing the context to the request in the first place solves that Greetings, Lukas
@s00500 do you think you could assist in contributing a test case for this? Would love to get it merged!
@tmc what is blocking the merge ?
A test demonstrating the problem. I’ll go ahead and merge this but I prefer test cases.
I believe this fixes #22.
I believe the WebSocket
r.Context()
should be passed to the newly created request object. When the WebSocket client disconnects,r.Context().Done()
is fired. Without passing this context to the newly created request, the wrapped handler is not aware when a disconnect happens (see #22).