heroku / heroku-pg

this code is now in https://github.com/heroku/cli
ISC License
15 stars 17 forks source link

does not exit cleanly if pg:psql postgres connection dies #82

Open msakrejda opened 7 years ago

msakrejda commented 7 years ago

Steps to repro:

  1. Run heroku pg:psql
  2. In a separate session, find the pid of the first session and run pg_terminate_backend (I think pg:killall would also work)
  3. Try to exit the original psql session with \q. You'll get the following error:
shogun-maciek::DATABASE=> \q
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:1007:11)
    at TCP.onread (net.js:563:26)
jdx commented 7 years ago

probably should still error out with ECONNRESET, but maybe not with the call stack.

msakrejda commented 7 years ago

Yeah, it's kinda weird, since if you don't quit immediately, psql will re-establish the session for you. Also, I can't seem to replicate this anymore, so maybe there's more to this. I'll leave it open in case someone else wants to try to repro...

msakrejda commented 7 years ago

Ok, I've looked some more into this and I can replicate it somewhat reliably, but I have no idea what's going on. The error handler we've added here doesn't trigger for this error, even though it does trigger correctly if, e.g., I change my PATH to exclude psql. I don't see where else we might be expected to install an error event handler, but the message clearly complains about a missing error handler. Could this be a node issue?

@dickeyxxx or @ransombriggs any ideas?

msakrejda commented 7 years ago

I think this might be related to #99