File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ Known incompatibilities:
4949
5050* ` connection.processID ` not implemented
5151* ` pool._pulseQueue ` not implemented
52+ * callback (CPS) interface not implemented (use promises instead)
5253
5354Please submit PR if you require additional compatibility.
5455
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export const createBridge = (postgres: typeof Postgres) => {
108108
109109 const compatibleConnection = {
110110 end : async ( ) => {
111- await connection . end ( ) ;
111+ await this . pool . destroy ( compatibleConnection ) ;
112112 } ,
113113 off : connectionEvents . off . bind ( connectionEvents ) ,
114114 on : connectionEvents . on . bind ( connectionEvents ) ,
@@ -190,9 +190,7 @@ export const createBridge = (postgres: typeof Postgres) => {
190190 }
191191
192192 public async end ( ) {
193- for ( const client of this . _clients ) {
194- await client . end ( ) ;
195- }
193+ await this . pool . clear ( ) ;
196194 }
197195 } ;
198196} ;
Original file line number Diff line number Diff line change @@ -117,6 +117,26 @@ for (const {
117117 await connection2 . end ( ) ;
118118 } ) ;
119119
120+ test ( clientName + ': pool.end() destroys all connections' , async ( t ) => {
121+ const pool = new Pool ( {
122+ user : 'postgres' ,
123+ } ) ;
124+
125+ t . is ( pool . totalCount , 0 ) ;
126+
127+ const connection1 = await pool . connect ( ) ;
128+ const connection2 = await pool . connect ( ) ;
129+
130+ t . is ( pool . totalCount , 2 ) ;
131+
132+ await connection1 . release ( ) ;
133+ await connection2 . release ( ) ;
134+
135+ await pool . end ( ) ;
136+
137+ t . is ( pool . totalCount , 0 ) ;
138+ } ) ;
139+
120140 test ( clientName + ': connection.release() releases connection back to the pool' , async ( t ) => {
121141 const pool = new Pool ( {
122142 user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments