Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notify/listen on channels longer than 63 characters silently fails without any error or warning #2

Open
jedwards1211 opened this issue Jun 14, 2021 · 0 comments

Comments

@jedwards1211
Copy link

System

  • Docker container: timescale/timescaledb:2.3.0-pg13
  • pg version: 8.6.0
  • pg-ipc version: 1.0.5

Repro code

const pgIPC = require('pg-ipc')
const pg = require('pg')
async function go() {
  var client = new pg.Client({...})
  var ipc = new pgIPC(client)
  ipc.on('error', console.error)
  await client.connect()
  ipc.on('test', console.log)
  ipc.notify('test', {value: 'test'})
  ipc.on('1234567890123456789012345678901234567890123456789012345678901234', console.log)
  ipc.notify('1234567890123456789012345678901234567890123456789012345678901234', {value: '64 chars'})
  ipc.notify('123456789012345678901234567890123456789012345678901234567890123', {value: '63 chars'})
}
go()

Actual behavior

I only see the output

NotificationResponseMessage {
  length: 30,
  processId: 2603,
  channel: 'test',
  payload: { value: 'test' },
  name: 'notification'
}

Expected behavior

Either it emits an 'error' of some kind, or I my listener for the 64-character '...1234' channel gets called.

What happens

The LISTEN/NOTIFY calls get truncated in Postgres to 63 characters. Postgres doesn't emit any errors for this, though it will raise a notice about it in the console.

So the last two notify calls, both for the 64-character '...1234' and the 63-character '...123' cause the pg.Client to emit notification events for the 63-character '...123' channel.

pg-ipc then emits events on that 63-character '...123' channel...but the listener was registered on the EventEmitter with the 64-character '...1234' channel. So the listener never gets called.

Solutions

I'd say either

  • truncate the channel to 63 characters when registering the listener on the EventEmitter (matching Postgres behavior)
  • OR throw an error if on/notify is called with a channel longer than 63 characters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant