Because the test server sends a close message shortly after sending a pong, the connection might close before our task handles the pong and calls its completion handler. In this case, the pong completion handler is never called, so try await task.sendPing() hangs indefinitely.
This PR cleans up pongCompletionHandlers on error/close and minimally fixes the test to allow the case where the server closes the connection before the pong is handled.
Because the test server sends a close message shortly after sending a pong, the connection might close before our task handles the pong and calls its completion handler. In this case, the pong completion handler is never called, so
try await task.sendPing()
hangs indefinitely.This PR cleans up
pongCompletionHandlers
on error/close and minimally fixes the test to allow the case where the server closes the connection before the pong is handled.