@@ -64,10 +64,11 @@ type ArrayParameter<T extends readonly any[] = readonly any[]> = Parameter<T | T
6464type SerializableParameter < T = never > = ArrayParameter | Parameter < any > | ReadonlyArray < SerializableParameter < T > > | Serializable | T | never ;
6565
6666export type BridgetClient = {
67- end : ( ) => void ,
67+ end : ( ) => Promise < void > ,
6868 off : ( eventName : string , listener : ( ...args : any [ ] ) => void ) => void ,
6969 on : ( eventName : string , listener : ( ...args : any [ ] ) => void ) => void ,
7070 query : ( sql : string , parameters : SerializableParameter [ ] ) => Promise < QueryResult > ,
71+ release : ( ) => Promise < void > ,
7172} ;
7273
7374export const createBridge = ( postgres : typeof Postgres ) => {
@@ -135,7 +136,7 @@ export const createBridge = (postgres: typeof Postgres) => {
135136 return compatibleConnection ;
136137 } ,
137138 destroy : async ( client : BridgetClient ) => {
138- client . end ( ) ;
139+ await client . end ( ) ;
139140 } ,
140141 } , {
141142 max : poolConfiguration . max ?? 10 ,
@@ -155,8 +156,8 @@ export const createBridge = (postgres: typeof Postgres) => {
155156 // TODO implement logic equivalent to https://github.com/brianc/node-postgres/blob/master/packages/pg-pool/index.js#L109-L152
156157 }
157158
158- public async _remove ( client : { end : ( ) => Promise < void > , } ) {
159- await client . end ( ) ;
159+ public async _remove ( client : BridgetClient ) {
160+ await this . pool . destroy ( client ) ;
160161
161162 this . poolEvents . emit ( 'remove' , client ) ;
162163 }
@@ -190,7 +191,7 @@ export const createBridge = (postgres: typeof Postgres) => {
190191
191192 public async end ( ) {
192193 for ( const client of this . _clients ) {
193- client . end ( ) ;
194+ await client . end ( ) ;
194195 }
195196 }
196197 } ;
0 commit comments