Skip to content

fix(pg-protocol): fail the stream when the parser throws on an unsupported message - #3843

Open
vtxe02023274 wants to merge 1 commit into
brianc:masterfrom
vtxe02023274:fix/3842-unsupported-auth-request
Open

vtxe02023274 wants to merge 1 commit into
brianc:masterfrom
vtxe02023274:fix/3842-unsupported-auth-request

Conversation

@vtxe02023274

Copy link
Copy Markdown

Closes #3842

When the server sends a message the parser cannot handle (for example AuthenticationGSS, code 7), parseAuthenticationResponse throws inside the socket's data listener. Nothing catches it, so it becomes an uncaught exception and the process exits instead of connect() rejecting.

parse() in pg-protocol now catches errors thrown by the parser and destroys the stream with that error. Connection already forwards stream errors, so connect() rejects while connecting and queries fail with the error afterwards. Errors thrown by the caller's callback are not touched and still propagate.

Tests: two cases in inbound-parser.test.ts (parser error fails the stream, callback error still throws) and gh-issues/3842-tests.js with a scripted server that answers the startup message with AuthenticationGSS. CI on my fork passes on all Node and PostgreSQL versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An authentication request pg-protocol does not support (GSSAPI, SSPI) crashes the process instead of failing connect()

1 participant