Repository navigation
fix(pg): keep the connection error as the cause of the "not queryable" error - #3853
Open
osama-akhter wants to merge 1 commit into
Open
osama-akhter wants to merge 1 commit into
osama-akhter wants to merge 1 commit into
Conversation
…" error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the server ends a connection with a FATAL error while no query is running, such as
idle_in_transaction_session_timeout(25P03), the client emits that error as'error'and marks itself not queryable. The next query fails withClient has encountered a connection error and is not queryable, a new error with no code and no link to the FATAL one. So code that sees only the query's error cannot tell an idle timeout from a dropped socket.The fix keeps the first error that made the client unqueryable and attaches it as the standard
causeof that error, in both the JS and the native client. It keeps the first one because the socket closing right after the FATAL raises a second, genericConnection terminated unexpectedlyerror. The message and the error type stay the same. On Node versions before 16.9 thecauseoption is ignored, so nothing changes there.Client was closed and is not queryableis unchanged: it follows a call toend(), with no error behind it.Tests:
idle_in_transaction_session_timeout, opens a transaction, waits for the server to end the connection, then runs a query: its error carries the25P03error ascause. It skips the native client, because libpq does not report a FATAL error while no query is running.cause.All fail on master and pass here.
Closes #3852
🤖 Generated with Claude Code