37
37
$do$;` ;
38
38
39
39
const decoder = new StringDecoder ( ) ;
40
- const pgliteDebugLog = fs . createWriteStream ( "pglite-debug.log" ) ;
41
40
42
41
export class PostgresServer {
43
42
private baseDataDirectory ?: string ;
@@ -283,8 +282,11 @@ export async function fromNodeSocket(socket: net.Socket, options?: PostgresConne
283
282
export class PGliteExtendedQueryPatch {
284
283
isExtendedQuery = false ;
285
284
eqpErrored = false ;
285
+ pgliteDebugLog : fs . WriteStream ;
286
286
287
- constructor ( public connection : PostgresConnection ) { }
287
+ constructor ( public connection : PostgresConnection ) {
288
+ this . pgliteDebugLog = fs . createWriteStream ( "pglite-debug.log" ) ;
289
+ }
288
290
289
291
async * filterResponse ( message : Uint8Array , response : Uint8Array ) {
290
292
// 'Parse' indicates the start of an extended query
@@ -295,7 +297,7 @@ export class PGliteExtendedQueryPatch {
295
297
] ;
296
298
const decoded = decoder . write ( message as any as Buffer ) ;
297
299
298
- pgliteDebugLog . write ( "Front: " + decoded ) ;
300
+ this . pgliteDebugLog . write ( "Front: " + decoded ) ;
299
301
300
302
if ( pipelineStartMessages . includes ( message [ 0 ] ) ) {
301
303
this . isExtendedQuery = true ;
@@ -319,10 +321,10 @@ export class PGliteExtendedQueryPatch {
319
321
}
320
322
// Filter out incorrect `ReadyForQuery` messages during the extended query protocol
321
323
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 ) ) ;
323
325
continue ;
324
326
}
325
- pgliteDebugLog . write ( "Sent: " + decoder . write ( bm as any as Buffer ) ) ;
327
+ this . pgliteDebugLog . write ( "Sent: " + decoder . write ( bm as any as Buffer ) ) ;
326
328
yield bm ;
327
329
}
328
330
}
0 commit comments