When reading an error message from the server during login, PgCat creates an array of bytes equal to the message length - vec![0u8; len as usize].
However Postgres includes the size in the length, and we already read it from the stream, so we end up trying to read more than what's in the buffer and eventually get an UnexpectedEof when Postgres closes the connection.
Describe the bug
When reading an error message from the server during login, PgCat creates an array of bytes equal to the message length -
vec![0u8; len as usize]
.However Postgres includes the size in the length, and we already read it from the stream, so we end up trying to read more than what's in the buffer and eventually get an UnexpectedEof when Postgres closes the connection.
https://github.com/postgresml/pgcat/blob/main/src/server.rs#L710-L712
We need to subtract
4
from the length similar to what is done for ReadyForQuery - https://github.com/postgresml/pgcat/blob/main/src/server.rs#L787To Reproduce
Expected behavior PgCat handles error messages from the server correctly during startup.
Screenshots N/A
Desktop (please complete the following information):
Additional context Add any other context about the problem here.