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
I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.35.2
What version of drizzle-kit are you using?
0.26.2
Other packages
No response
Describe the Bug
If a pg.Client receives an ErrorMessage from the PostgreSQL server, it will eventually emit an error event.
One could argue that installing such a handler would the task of whoever provides the client to Drizzle. However, that only works with individual clients. When passing a pg.Pool to Drizzle, the caller no longer has control of the individual client instances and therefore cannot easily do so, at least not without hacks like overriding the method. Unfortunately, when acquiring a connection from a pg.Pool, Drizzle does not install a listener for the error event itself. Due to Node's special handling of the error event, this crashes the entire process when it does occur.
In this case, what happened was that someone on the server invoked pg_terminate_backend() for debugging purposes. It should thus be possible to reproduce this error by, e.g., sleeping (on the client) inside a transaction and then using pg_terminate_backend() to kill it from the server side.
Edit to add: Since I didn't clarify above, we are using node-postgres, i.e., the pg and pg-pool packages.
The text was updated successfully, but these errors were encountered:
To add some information: node-postgres documentation mentions that while there are outstanding promises for connect()/query()/end() operations, errors are caught and transformed into promise rejections.
I believe the issue occurred as follows: A transaction() callback was suspended awaiting an unrelated promise, i.e., not in a query, and that's when the error was raised and why it wasn't caught automatically. I updated the issue body to clarify that for the repro instructions.
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.35.2
What version of
drizzle-kit
are you using?0.26.2
Other packages
No response
Describe the Bug
If a
pg.Client
receives anErrorMessage
from the PostgreSQL server, it will eventually emit anerror
event.One could argue that installing such a handler would the task of whoever provides the client to Drizzle. However, that only works with individual clients. When passing a
pg.Pool
to Drizzle, the caller no longer has control of the individual client instances and therefore cannot easily do so, at least not without hacks like overriding the method. Unfortunately, when acquiring a connection from apg.Pool
, Drizzle does not install a listener for the error event itself. Due to Node's special handling of theerror
event, this crashes the entire process when it does occur.In this case, what happened was that someone on the server invoked
pg_terminate_backend()
for debugging purposes. It should thus be possible to reproduce this error by, e.g., sleeping (on the client) inside a transaction and then usingpg_terminate_backend()
to kill it from the server side.Edit to add: Since I didn't clarify above, we are using
node-postgres
, i.e., thepg
andpg-pool
packages.The text was updated successfully, but these errors were encountered: