Skip to content

Commit 7fcf941

Browse files
authored
Improve race condition in pg-native cancel test (brianc#3234)
1 parent b3f0ddd commit 7fcf941

File tree

3 files changed

+10
-45
lines changed

3 files changed

+10
-45
lines changed

packages/pg-native/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"homepage": "https://github.com/brianc/node-pg-native",
2424
"dependencies": {
2525
"libpq": "1.8.13",
26-
"pg-types": "^1.12.1",
27-
"readable-stream": "1.0.31"
26+
"pg-types": "^1.12.1"
2827
},
2928
"devDependencies": {
3029
"async": "^0.9.0",

packages/pg-native/test/cancel.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ describe('cancel query', function () {
55
it('works', function (done) {
66
var client = new Client()
77
client.connectSync()
8-
client.query('SELECT pg_sleep(100);', function (err) {
8+
client.query('SELECT pg_sleep(1000);', function (err) {
99
assert(err instanceof Error)
1010
client.end(done)
1111
})
12-
client.cancel(function (err) {
13-
assert.ifError(err)
14-
})
12+
setTimeout(() => {
13+
client.cancel(function (err) {
14+
assert.ifError(err)
15+
})
16+
}, 100)
1517
})
1618

1719
it('does not raise error if no active query', function (done) {

yarn.lock

+3-39
Original file line numberDiff line numberDiff line change
@@ -3968,7 +3968,7 @@ inflight@^1.0.4:
39683968
once "^1.3.0"
39693969
wrappy "1"
39703970

3971-
inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3:
3971+
inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3:
39723972
version "2.0.4"
39733973
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
39743974
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
@@ -4276,11 +4276,6 @@ is-windows@^1.0.0, is-windows@^1.0.2:
42764276
resolved "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz"
42774277
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
42784278

4279-
4280-
version "0.0.1"
4281-
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
4282-
integrity sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==
4283-
42844279
[email protected], isarray@~1.0.0:
42854280
version "1.0.0"
42864281
resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
@@ -6283,16 +6278,6 @@ read@1, read@~1.0.1:
62836278
string_decoder "~1.1.1"
62846279
util-deprecate "~1.0.1"
62856280

6286-
6287-
version "1.0.31"
6288-
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.31.tgz#8f2502e0bc9e3b0da1b94520aabb4e2603ecafae"
6289-
integrity sha512-tco/Dwv1f/sgIgN6CWdj/restacPKNskK6yps1981ivH2ZmLYcs5o5rVzL3qaO/cSkhN8hYOMWs7+glzOLSgRg==
6290-
dependencies:
6291-
core-util-is "~1.0.0"
6292-
inherits "~2.0.1"
6293-
isarray "0.0.1"
6294-
string_decoder "~0.10.x"
6295-
62966281
"readable-stream@2 || 3", readable-stream@^3.0.2:
62976282
version "3.6.0"
62986283
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz"
@@ -6943,7 +6928,7 @@ stream-spec@~0.3.5:
69436928
dependencies:
69446929
macgyver "~1.10"
69456930

6946-
"string-width-cjs@npm:string-width@^4.2.0":
6931+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
69476932
version "4.2.3"
69486933
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
69496934
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -6978,15 +6963,6 @@ string-width@^3.0.0, string-width@^3.1.0:
69786963
is-fullwidth-code-point "^2.0.0"
69796964
strip-ansi "^5.1.0"
69806965

6981-
string-width@^4.1.0:
6982-
version "4.2.3"
6983-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
6984-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
6985-
dependencies:
6986-
emoji-regex "^8.0.0"
6987-
is-fullwidth-code-point "^3.0.0"
6988-
strip-ansi "^6.0.1"
6989-
69906966
string-width@^5.0.1, string-width@^5.1.2:
69916967
version "5.1.2"
69926968
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
@@ -7019,19 +6995,14 @@ string_decoder@^1.1.1:
70196995
dependencies:
70206996
safe-buffer "~5.2.0"
70216997

7022-
string_decoder@~0.10.x:
7023-
version "0.10.31"
7024-
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
7025-
integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==
7026-
70276998
string_decoder@~1.1.1:
70286999
version "1.1.1"
70297000
resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz"
70307001
integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
70317002
dependencies:
70327003
safe-buffer "~5.1.0"
70337004

7034-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
7005+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
70357006
version "6.0.1"
70367007
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
70377008
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -7059,13 +7030,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
70597030
dependencies:
70607031
ansi-regex "^4.1.0"
70617032

7062-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
7063-
version "6.0.1"
7064-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
7065-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
7066-
dependencies:
7067-
ansi-regex "^5.0.1"
7068-
70697033
strip-ansi@^7.0.1:
70707034
version "7.1.0"
70717035
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"

0 commit comments

Comments
 (0)