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:
4242* ` pool.connect `
4343* ` connection.query `
4444* ` connect ` event
45+ * ` remove ` event
4546* ` notice ` event
4647
4748Known incompatibilities:
Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ export const createBridge = (postgres: typeof Postgres) => {
157157
158158 public async _remove ( client : { end : ( ) => Promise < void > , } ) {
159159 await client . end ( ) ;
160+
161+ this . poolEvents . emit ( 'remove' , client ) ;
160162 }
161163
162164 public get _clients ( ) : BridgetClient [ ] {
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ for (const {
4242 t . is ( spy . firstCall . args [ 0 ] , connection ) ;
4343 } ) ;
4444
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+
4563 test ( clientName + ': "notice event is fired when connection produces a notice"' , async ( t ) => {
4664 const pool = new Pool ( {
4765 user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments