You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Connection errors are not handled in client.query unless on('error') is defined. #2191
if connection error happens during client.query() a error should be thrown(or callback error)
if connection error happens when no queries are running(connection idle), on('error') should be emitted.
Actual behaviour:
if connection error happens during client.query() and client.on('error') is not attached, no error is returned from query() and since on('error') is missing a process gets unhandledException and probably dies
if connection error happens during client.query() and client.on('error') is attached, client.query() throws error correctly.
This only applies to connection erros, SQL errors are always thrown.
you can play with it with following code: if let it run, you see invalid query errors are caught, but if you stop postgres, it query() does not throw, and due to unhandled error process dies. But if you uncomment on('error') handler, a error is handled in the event handler, and query() correctly
if connection error happens during client.query() and client.on('error') is not attached, no error is returned from query() and since on('error') is missing a process gets unhandledException and probably dies
I think the query promise would reject if the process didn’t end because of the uncaught error first.
Activity
charmander commentedon May 4, 2020
I think the query promise would reject if the process didn’t end because of the uncaught error first.
markddrake commentedon May 4, 2020
I think this is similar to the issue I am having with pg-query-stream() and aborted connections..
##2187
except that in my case the behavior changed between 2.x and 3.x
joras commentedon May 4, 2020
ok, that could be, but is that expected behaviour? In that case the documentation needs to be updated.