Skip to content

Commit e1b8272

Browse files
authored
Fix top level writeStream breaking functions. (#8824)
* Fix top level write * format
1 parent 7d7ee95 commit e1b8272

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed an issue where `firebase-tools` could not be used within v1 Cloud Functions due to trying to write to a read only file.

src/emulator/dataconnect/pgliteServer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ END
3737
$do$;`;
3838

3939
const decoder = new StringDecoder();
40-
const pgliteDebugLog = fs.createWriteStream("pglite-debug.log");
4140

4241
export class PostgresServer {
4342
private baseDataDirectory?: string;
@@ -283,8 +282,11 @@ export async function fromNodeSocket(socket: net.Socket, options?: PostgresConne
283282
export 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

Comments
 (0)