File tree 3 files changed +23
-4
lines changed 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ Known incompatibilities:
49
49
50
50
* ` connection.processID ` not implemented
51
51
* ` pool._pulseQueue ` not implemented
52
+ * callback (CPS) interface not implemented (use promises instead)
52
53
53
54
Please submit PR if you require additional compatibility.
54
55
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export const createBridge = (postgres: typeof Postgres) => {
108
108
109
109
const compatibleConnection = {
110
110
end : async ( ) => {
111
- await connection . end ( ) ;
111
+ await this . pool . destroy ( compatibleConnection ) ;
112
112
} ,
113
113
off : connectionEvents . off . bind ( connectionEvents ) ,
114
114
on : connectionEvents . on . bind ( connectionEvents ) ,
@@ -190,9 +190,7 @@ export const createBridge = (postgres: typeof Postgres) => {
190
190
}
191
191
192
192
public async end ( ) {
193
- for ( const client of this . _clients ) {
194
- await client . end ( ) ;
195
- }
193
+ await this . pool . clear ( ) ;
196
194
}
197
195
} ;
198
196
} ;
Original file line number Diff line number Diff line change @@ -117,6 +117,26 @@ for (const {
117
117
await connection2 . end ( ) ;
118
118
} ) ;
119
119
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
+
120
140
test ( clientName + ': connection.release() releases connection back to the pool' , async ( t ) => {
121
141
const pool = new Pool ( {
122
142
user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments