3737$do$;` ;
3838
3939const decoder = new StringDecoder ( ) ;
40- const pgliteDebugLog = fs . createWriteStream ( "pglite-debug.log" ) ;
4140
4241export class PostgresServer {
4342 private baseDataDirectory ?: string ;
@@ -283,8 +282,11 @@ export async function fromNodeSocket(socket: net.Socket, options?: PostgresConne
283282export class PGliteExtendedQueryPatch {
284283 isExtendedQuery = false ;
285284 eqpErrored = false ;
285+ pgliteDebugLog : fs . WriteStream ;
286286
287- constructor ( public connection : PostgresConnection ) { }
287+ constructor ( public connection : PostgresConnection ) {
288+ this . pgliteDebugLog = fs . createWriteStream ( "pglite-debug.log" ) ;
289+ }
288290
289291 async * filterResponse ( message : Uint8Array , response : Uint8Array ) {
290292 // 'Parse' indicates the start of an extended query
@@ -295,7 +297,7 @@ export class PGliteExtendedQueryPatch {
295297 ] ;
296298 const decoded = decoder . write ( message as any as Buffer ) ;
297299
298- pgliteDebugLog . write ( "Front: " + decoded ) ;
300+ this . pgliteDebugLog . write ( "Front: " + decoded ) ;
299301
300302 if ( pipelineStartMessages . includes ( message [ 0 ] ) ) {
301303 this . isExtendedQuery = true ;
@@ -319,10 +321,10 @@ export class PGliteExtendedQueryPatch {
319321 }
320322 // Filter out incorrect `ReadyForQuery` messages during the extended query protocol
321323 if ( this . isExtendedQuery && bm [ 0 ] === BackendMessageCode . ReadyForQuery ) {
322- pgliteDebugLog . write ( "Filtered: " + decoder . write ( bm as any as Buffer ) ) ;
324+ this . pgliteDebugLog . write ( "Filtered: " + decoder . write ( bm as any as Buffer ) ) ;
323325 continue ;
324326 }
325- pgliteDebugLog . write ( "Sent: " + decoder . write ( bm as any as Buffer ) ) ;
327+ this . pgliteDebugLog . write ( "Sent: " + decoder . write ( bm as any as Buffer ) ) ;
326328 yield bm ;
327329 }
328330 }
0 commit comments