permitio / fastapi_websocket_rpc

⚡ FASTAPI Websocket RPC- A fast and durable bidirectional JSON RPC channel over Websockets.
https://permit.io
MIT License
216 stars 25 forks source link

WebSocketRpcClient's connect leaks memory on failure #13

Closed roekatz closed 2 years ago

roekatz commented 2 years ago

This would happen when retries are enabled.

WebSocketRpcClient.__aenter__ retries connecting indefinitely:

return await retry(**self.retry_config)(self.__connect__)()

If __connect__ keeps failing - memory usage gradually increases (more noticeably when configuring fast retry strategy). This is due to __connect__ not cleaning resources on exceptions:

This was found while debugging: https://github.com/permitio/opal/issues/274

roekatz commented 2 years ago

Fix merged