@@ -120,7 +120,7 @@ for (const {
120
120
await connection2 . end ( ) ;
121
121
} ) ;
122
122
123
- test ( clientName + ': pool.end() immediately resolves if all connections are released' , async ( t ) => {
123
+ test ( clientName + ': pool.end() resolves immediately if all connections are released' , async ( t ) => {
124
124
const pool = new Pool ( {
125
125
user : 'postgres' ,
126
126
} ) ;
@@ -147,6 +147,36 @@ for (const {
147
147
t . is ( pool . totalCount , 0 ) ;
148
148
} ) ;
149
149
150
+ // This appears to be a bug in pg-pool
151
+ // https://github.com/brianc/node-postgres/issues/2778
152
+ // eslint-disable-next-line ava/no-skip-test
153
+ test . skip ( clientName + ': pool.end() resolves immediately if all connections are ended' , async ( t ) => {
154
+ const pool = new Pool ( {
155
+ user : 'postgres' ,
156
+ } ) ;
157
+
158
+ t . is ( pool . totalCount , 0 ) ;
159
+
160
+ const connection1 = await pool . connect ( ) ;
161
+ const connection2 = await pool . connect ( ) ;
162
+
163
+ t . is ( pool . totalCount , 2 ) ;
164
+
165
+ await connection1 . end ( ) ;
166
+ await connection2 . end ( ) ;
167
+
168
+ const startTime = Date . now ( ) ;
169
+
170
+ await pool . end ( ) ;
171
+
172
+ const duration = Date . now ( ) - startTime ;
173
+
174
+ // If duration is longer than a couple milliseconds then something is off.
175
+ t . true ( duration < 10 ) ;
176
+
177
+ t . is ( pool . totalCount , 0 ) ;
178
+ } ) ;
179
+
150
180
test ( clientName + ': connection.release() releases connection back to the pool' , async ( t ) => {
151
181
const pool = new Pool ( {
152
182
user : 'postgres' ,
0 commit comments