File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,20 +6,6 @@ permissions:
66 contents : read
77
88jobs :
9- lint :
10- timeout-minutes : 5
11- runs-on : ubuntu-latest
12- steps :
13- - uses : actions/checkout@v4
14- with :
15- persist-credentials : false
16- - name : Setup node
17- uses : actions/setup-node@v4
18- with :
19- node-version : 18
20- cache : yarn
21- - run : yarn install --frozen-lockfile
22- - run : yarn lint
239 build :
2410 timeout-minutes : 15
2511 needs : lint
3824 fail-fast : false
3925 matrix :
4026 node :
41- - ' 16'
42- - ' 18'
43- - ' 20'
4427 - ' 22'
45- - ' 23'
4628 os :
4729 - ubuntu-latest
4830 name : Node.js ${{ matrix.node }}
7254 node-version : ${{ matrix.node }}
7355 cache : yarn
7456 - run : yarn install --frozen-lockfile
75- - run : yarn test
57+ - run : cd packages/pg-pool && yarn test
Original file line number Diff line number Diff line change @@ -25,23 +25,25 @@ describe('idle timeout', () => {
2525 it (
2626 'times out and removes clients when others are also removed' ,
2727 co . wrap ( function * ( ) {
28- let currentClient = 1
2928 const pool = new Pool ( { idleTimeoutMillis : 10 } )
3029 const clientA = yield pool . connect ( )
3130 const clientB = yield pool . connect ( )
32- clientA . release ( )
33- clientB . release ( new Error ( ) )
31+ clientA . release ( ) // this will put clientA in the idle pool
32+ clientB . release ( new Error ( ) ) // an error will cause clientB to be removed immediately
3433
3534 const removal = new Promise ( ( resolve ) => {
36- pool . on ( 'remove' , ( ) => {
35+ pool . on ( 'remove' , ( client ) => {
36+ // clientB's stream may take a while to close, so we may get a remove
37+ // event for it
38+ // we only want to handle the remove event for clientA when it times out
39+ // due to being idle
40+ if ( client !== clientA ) {
41+ return
42+ }
43+
3744 expect ( pool . idleCount ) . to . equal ( 0 )
3845 expect ( pool . totalCount ) . to . equal ( 0 )
39-
40- if ( currentClient >= 2 ) {
41- resolve ( )
42- } else {
43- currentClient ++
44- }
46+ resolve ( )
4547 } )
4648 } )
4749
@@ -50,7 +52,7 @@ describe('idle timeout', () => {
5052 try {
5153 yield Promise . race ( [ removal , timeout ] )
5254 } finally {
53- yield pool . end ( )
55+ pool . end ( )
5456 }
5557 } )
5658 )
You can’t perform that action at this time.
0 commit comments