edgedb / edgedb-net

The official .NET client library for EdgeDB
https://edgedb.com
Apache License 2.0
82 stars 9 forks source link

Fix reconnection deadlock on auth phase #42

Closed quinchs closed 1 year ago

quinchs commented 1 year ago

Summary

When the binding receives an ErrorResponse from the server during the authentication phase, it will attempt to reconnect. The issue with this is that the ConnectAsync method is gated with a single permit semaphore which causes a deadlock in the following:

ConnectAsync
-> HandlePacketAsync
     -> (ErrorResponse) ReconnectAsync
          -> ConnectAsync

This PR fixes this by controlling the reconnect logic in the ConnectAsync method rather than its dependents.

Fixes #39