File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/pg-driver/src/factories Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -340,13 +340,22 @@ export const createPgDriverFactory = (): DriverFactory => {
340340 // `rowDescription` will not fire if the query produces a syntax error.
341341 // Also, `rowDescription` won't fire until client starts consuming the stream.
342342 // This is why we cannot simply await for `rowDescription` event before starting to pipe the stream.
343- client . connection . once ( 'rowDescription' , ( rowDescription ) => {
343+ const onRowDescription = ( rowDescription ) => {
344344 fields = rowDescription . fields . map ( ( field ) => {
345345 return {
346346 dataTypeId : field . dataTypeID ,
347347 name : field . name ,
348348 } ;
349349 } ) ;
350+ } ;
351+
352+ client . connection . once ( 'rowDescription' , onRowDescription ) ;
353+
354+ stream . once ( 'close' , ( ) => {
355+ client . connection . removeListener (
356+ 'rowDescription' ,
357+ onRowDescription ,
358+ ) ;
350359 } ) ;
351360
352361 const transform = new Transform ( {
You can’t perform that action at this time.
0 commit comments