Skip to content

Commit 042194f

Browse files
committed
Update aftr rebase
1 parent e473b4a commit 042194f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

test/integration/connection-pool/error-tests.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22
var helper = require('./test-helper')
33
const pg = helper.pg
4+
const native = helper.args.native
45

56
const suite = new helper.Suite()
67
suite.test('connecting to invalid port', (cb) => {
@@ -102,14 +103,28 @@ suite.test('connection-level errors cause future queries to fail', (cb) => {
102103

103104
suite.test('handles socket error during pool.query and destroys it immediately', (cb) => {
104105
const pool = new pg.Pool({ max: 1 })
105-
pool.query('SELECT pg_sleep(10)', [], (err) => {
106-
assert.equal(err.message, 'network issue')
107-
assert.equal(stream.destroyed, true)
108-
cb()
109-
})
110106

111-
const stream = pool._clients[0].connection.stream
112-
setTimeout(() => {
113-
stream.emit('error', new Error('network issue'))
114-
}, 100)
107+
if (native) {
108+
pool.query('SELECT pg_sleep(10)', [], (err) => {
109+
assert.equal(err.message, 'canceling statement due to user request')
110+
cb()
111+
})
112+
113+
setTimeout(() => {
114+
pool._clients[0].native.cancel((err) => {
115+
assert.ifError(err)
116+
})
117+
}, 100)
118+
} else {
119+
pool.query('SELECT pg_sleep(10)', [], (err) => {
120+
assert.equal(err.message, 'network issue')
121+
assert.equal(stream.destroyed, true)
122+
cb()
123+
})
124+
125+
const stream = pool._clients[0].connection.stream
126+
setTimeout(() => {
127+
stream.emit('error', new Error('network issue'))
128+
}, 100)
129+
}
115130
})

0 commit comments

Comments
 (0)