hasura / pg-client-hs

A low level Haskell library to connect to postgres
Apache License 2.0
25 stars 15 forks source link

failed to allocate cancel handle error is confusing and misleading #63

Closed ecthiender closed 2 years ago

ecthiender commented 2 years ago

When we are unable to get a cancel data structure from a connection, we throw the error - failed to allocate cancel handle (ref). The libpq library states that this can only happen when the connection is invalid (ref).

So this becomes confusing and misleading for a user of this library as it seems there is some issue with the cancellation feature, when actually the connection is invalid. The user may or may not see the actual error message/reason from Postgres, depending upon if they have setup exception handling. An appropriate way to handle this error would be throw an invalid connection error, but we don't have details on why the connection is invalid. If we let postgres throw the error, it will have the actual error message/reason for the invalid connection. Hence, it makes sense to not setup the cancellation here and try to run the query, which will fail with proper error message from Postgres.

See originating issue - https://github.com/hasura/graphql-engine-mono/issues/4158