brianc / node-pg-pool

A connection pool for node-postgres
MIT License
180 stars 64 forks source link

pool.on('error') Documentation Inaccurate #138

Open jerroydmoore opened 4 years ago

jerroydmoore commented 4 years ago

Greetings everyone,

I believe the documentation for pool.on('error') is inaccurate/incomplete.

The documentation directs users to "handle this in the same way you would treat process.on('uncaughtException')". The uncaughtException event discourages users from recovering the application: "Unhandled exceptions inherently mean that an application is in an undefined state. Attempting to resume application code without properly recovering from the exception can cause additional unforeseen and unpredictable issues."

After reading through https://github.com/brianc/node-postgres/issues/1075 and https://github.com/brianc/node-postgres/issues/1558. @charmander briefly mentions that pg.Pool will handle reconnecting pg.Client after restarting Postgres: "A pg.Pool will handle this for you, even if you never want more than one client."

Given that pg.Pool can recover from client errors, I think this should be included in the documentation about error handling.