File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ Supported features:
42
42
* ` pool.connect `
43
43
* ` connection.query `
44
44
* ` connect ` event
45
+ * ` remove ` event
45
46
* ` notice ` event
46
47
47
48
Known incompatibilities:
Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ export const createBridge = (postgres: typeof Postgres) => {
157
157
158
158
public async _remove ( client : { end : ( ) => Promise < void > , } ) {
159
159
await client . end ( ) ;
160
+
161
+ this . poolEvents . emit ( 'remove' , client ) ;
160
162
}
161
163
162
164
public get _clients ( ) : BridgetClient [ ] {
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ for (const {
42
42
t . is ( spy . firstCall . args [ 0 ] , connection ) ;
43
43
} ) ;
44
44
45
+ test ( clientName + ': "remove" event is fired when connection is removed' , async ( t ) => {
46
+ const pool = new Pool ( {
47
+ user : 'postgres' ,
48
+ } ) ;
49
+
50
+ const spy = sinon . spy ( ) ;
51
+
52
+ pool . on ( 'remove' , spy ) ;
53
+
54
+ const connection = await pool . connect ( ) ;
55
+
56
+ await pool . _remove ( connection ) ;
57
+
58
+ t . true ( spy . called ) ;
59
+
60
+ t . is ( spy . firstCall . args [ 0 ] , connection ) ;
61
+ } ) ;
62
+
45
63
test ( clientName + ': "notice event is fired when connection produces a notice"' , async ( t ) => {
46
64
const pool = new Pool ( {
47
65
user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments