@@ -64,10 +64,11 @@ type ArrayParameter<T extends readonly any[] = readonly any[]> = Parameter<T | T
64
64
type SerializableParameter < T = never > = ArrayParameter | Parameter < any > | ReadonlyArray < SerializableParameter < T > > | Serializable | T | never ;
65
65
66
66
export type BridgetClient = {
67
- end : ( ) => void ,
67
+ end : ( ) => Promise < void > ,
68
68
off : ( eventName : string , listener : ( ...args : any [ ] ) => void ) => void ,
69
69
on : ( eventName : string , listener : ( ...args : any [ ] ) => void ) => void ,
70
70
query : ( sql : string , parameters : SerializableParameter [ ] ) => Promise < QueryResult > ,
71
+ release : ( ) => Promise < void > ,
71
72
} ;
72
73
73
74
export const createBridge = ( postgres : typeof Postgres ) => {
@@ -135,7 +136,7 @@ export const createBridge = (postgres: typeof Postgres) => {
135
136
return compatibleConnection ;
136
137
} ,
137
138
destroy : async ( client : BridgetClient ) => {
138
- client . end ( ) ;
139
+ await client . end ( ) ;
139
140
} ,
140
141
} , {
141
142
max : poolConfiguration . max ?? 10 ,
@@ -155,8 +156,8 @@ export const createBridge = (postgres: typeof Postgres) => {
155
156
// TODO implement logic equivalent to https://github.com/brianc/node-postgres/blob/master/packages/pg-pool/index.js#L109-L152
156
157
}
157
158
158
- public async _remove ( client : { end : ( ) => Promise < void > , } ) {
159
- await client . end ( ) ;
159
+ public async _remove ( client : BridgetClient ) {
160
+ await this . pool . destroy ( client ) ;
160
161
161
162
this . poolEvents . emit ( 'remove' , client ) ;
162
163
}
@@ -190,7 +191,7 @@ export const createBridge = (postgres: typeof Postgres) => {
190
191
191
192
public async end ( ) {
192
193
for ( const client of this . _clients ) {
193
- client . end ( ) ;
194
+ await client . end ( ) ;
194
195
}
195
196
}
196
197
} ;
0 commit comments