brianc / node-pg-pool

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

Testing with fakeTimers and pg-pool results in "Connection terminated by user" #92

Closed TheFive closed 6 years ago

TheFive commented 6 years ago

Hi,

Before: This is not a bug in pg-pool, this is a problem in my test scripts.

I am using pg for a long time and have no switched to the new version using pg-pool.

In my mocha test environment I got very often the error message:

{ message: 'Connection terminated by user' }

depending on which time I put in this configuration

connectionTimeoutMillis: 500,
idleTimeoutMillis: 500

After reducing the problem, the source was found, it was sinon.useFakeTimers in parallel with pg-pool

Ok, that a pool, that is managed by timeout, and a "stopped" timer are clashing is not really a surprise.

Does anyone has a hint how i can get working "simulated time" and pg-pool together ?

TheFive commented 6 years ago

i have switched to mockdate which fits my need, and is working without trouble.