brianc / node-pg-pool

A connection pool for node-postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

TheFive opened this issue · comments

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 ?

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