UNPKG

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