pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Channel name with hyphen does not work

Open juhamust opened this issue 7 months ago • 1 comments

If PGlite pool attempts to listen to a channel name containing a hyphen, it gives an error shown below. Underscore works.

Code:

import { PGlite } from '@electric-sql/pglite';

async function main() {
  const pool = await PGlite.create();
  const channelName = 'name-with-hyphen';

  const unsubscribe = await pool.listen(channelName, (data: any) => {
    console.log(data);
  });

  unsubscribe();
  await pool.close();
}

main().catch(console.error);

Output:

error: syntax error at or near "-"
    at Ue.Lr (/Users/me/Projects/foo/node_modules/@electric-sql/pg-protocol/src/parser.ts:432:11)
    at Ue.ba (/Users/me/Projects/foo/node_modules/@electric-sql/pg-protocol/src/parser.ts:210:16)
    at Ue.parse (/Users/me/Projects/foo/node_modules/@electric-sql/pg-protocol/src/parser.ts:102:25)
    at dr.execProtocol (/Users/me/Projects/foo/node_modules/@electric-sql/pglite/src/pglite.ts:700:26)
    at async dr.oe (/Users/me/Projects/foo/node_modules/@electric-sql/pglite/src/base.ts:139:12)
    at async /Users/me/Projects/foo/node_modules/@electric-sql/pglite/src/base.ts:313:11 {
  length: 90,
  severity: 'ERROR',
  code: '42601',
  detail: undefined,
  hint: undefined,
  position: '12',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'scan.l',
  line: '1248',
  routine: 'scanner_yyerror'
}

juhamust avatar Jul 30 '25 05:07 juhamust

This issue is somewhat related to https://github.com/electric-sql/pglite/issues/642

juhamust avatar Jul 30 '25 13:07 juhamust