Skip to content

Commit cbce34a

Browse files
committed
Invalidate connection after client-side timeout.
The `query_timeout` feature of the `pg` package helps handle stuck TCP connections more quickly and gracefully by implementing a client-side timeout: brianc/node-postgres#1713 Sequelize started passing this dialect-specific option through to `pg` here: sequelize#13258 I believe we also want to invalidate the connection when a client-side timeout occurs. We shouldn't try to reuse the stuck connection because...it's stuck. This PR updates the error handling code so that the connection is invalidated if the error matches the one thrown from here: https://github.com/brianc/node-postgres/blob/5538df6b446f4b4f921947b460fe38acb897e579/packages/pg/lib/client.js#L529
1 parent fe3f470 commit cbce34a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/dialects/postgres/query.js

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class PostgresQuery extends AbstractQuery {
5151
|| /Unable to set non-blocking to true/i.test(error)
5252
|| /SSL SYSCALL error: EOF detected/i.test(error)
5353
|| /Local: Authentication failure/i.test(error)
54+
|| error.message === 'Query read timeout'
5455
) {
5556
connection._invalid = true;
5657
}

0 commit comments

Comments
 (0)