idle-timeout-exit.js 579 B

1234567891011121314151617
  1. // This test is meant to be spawned from idle-timeout.js
  2. if (module === require.main) {
  3. const allowExitOnIdle = process.env.ALLOW_EXIT_ON_IDLE === '1'
  4. const Pool = require('../index')
  5. const pool = new Pool({ idleTimeoutMillis: 200, ...(allowExitOnIdle ? { allowExitOnIdle: true } : {}) })
  6. pool.query('SELECT NOW()', (err, res) => console.log('completed first'))
  7. pool.on('remove', () => {
  8. console.log('removed')
  9. done()
  10. })
  11. setTimeout(() => {
  12. pool.query('SELECT * from generate_series(0, 1000)', (err, res) => console.log('completed second'))
  13. }, 50)
  14. }