brianc/node-postgres-docs

client.connect() returns misleading error

Herald85 opened this issue · 1 comments

I'm working with Docker on W10 and it takes DB a bit longer to start than my app container and I was getting Error: connect ECONNREFUSED... from client.connect(). I wanted to solve it with a timer loop with try to connect every 1 second again, but each other call of client.connect() returned an error Client has already been connected.... And that was not true, DB still hasn't started and any query called on such client ended with an error. What I had to do was to close the client and create a completely new instance on which I could try to call connect again.

My points are:

  • connect should be allowed to be called multiple times on one instance if the previous call ended with connection error
  • even if that is not wanted, the error message should not say Client has already been connected, when it is not true (again DB has not yet started)

Still experiencing this issue today.