Duplicate notifications when subscribing to a publication with postgresjs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
I have created a publication in PostgreSQL and I'm using subscribe to listen to changes. I'm using this code:
const { unsubscribe } = await sql.subscribe(
'update:users',
(row, { command, relation, key, old }) => {
console.log(row, key, old)
}
)
The problem is that my callback is called twice when I'm updating a record on the users table. Also, I get false for key and null for old in both callbacks. Is there any bug in the implementation or did I do something wrong?
Expected behavior:
I expect the callback to be called only once when I update a record on the users table. I also expect to get the correct values for key and old in the callback.
Actual behavior:
The callback is called twice when I update a record on the users table. I get false for key and null for old in both callbacks.
Environment:
• postgres version: ^3.4.3
• PostgreSQL version: docker image: postgres:15.1
• Node.js version: v18.18.2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied sql.subscribe example with PostgreSQL 15.1 and the stated Node.js environment, then trace the subscription handling used by postgresjs. Done means an update produces one callback with the correct key and old values, with tests or reproduction evidence covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100