Skip to content

Commit a227038

Browse files
fix(postgres-emitter): use parameterized query to send the NOTIFY command
1 parent c714492 commit a227038

File tree

1 file changed

+8
-6
lines changed
  • packages/socket.io-postgres-emitter/lib

1 file changed

+8
-6
lines changed

packages/socket.io-postgres-emitter/lib/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,10 @@ export class BroadcastOperator<
380380
document.type,
381381
this.emitter.channel,
382382
);
383-
await this.emitter.pool.query(
384-
`NOTIFY "${this.emitter.channel}", '${payload}'`,
385-
);
383+
await this.emitter.pool.query("SELECT pg_notify($1, $2)", [
384+
this.emitter.channel,
385+
payload,
386+
]);
386387
} catch (err) {
387388
// @ts-ignore
388389
this.emit("error", err);
@@ -407,9 +408,10 @@ export class BroadcastOperator<
407408
type: document.type,
408409
attachmentId,
409410
});
410-
this.emitter.pool.query(
411-
`NOTIFY "${this.emitter.channel}", '${headerPayload}'`,
412-
);
411+
await this.emitter.pool.query("SELECT pg_notify($1, $2)", [
412+
this.emitter.channel,
413+
headerPayload,
414+
]);
413415
}
414416

415417
/**

0 commit comments

Comments
 (0)