Skip to content

Keep original LISTEN unsubscribe handles valid across reconnects - #1244

Open
CheckPickerUpper wants to merge 1 commit into
porsager:masterfrom
CheckPickerUpper:1243-listen-unsubscribe
Open

CheckPickerUpper wants to merge 1 commit into
porsager:masterfrom
CheckPickerUpper:1243-listen-unsubscribe

Conversation

@CheckPickerUpper

@CheckPickerUpper CheckPickerUpper commented Oct 5, 2026 •

Copy link
Copy Markdown

After a LISTEN connection reconnects, the original unlisten() handle resolves successfully while leaving its replacement callback registered. Preserve the listener object issued by the public call and reuse it during native reconnect. Check current membership before invoking onlisten, so a handle closed while registration is pending cannot announce that subscription ready.

The existing native runner now covers original unsubscribe after reconnect with two listeners on the same channel, release of the last server LISTEN registration while ordinary queries remain available, and unsubscribe before a pending reconnect readiness callback. User callbacks provide positive observation barriers. The normal test entrypoint registers both scenarios through tests/listen-reconnect.js; each retains the runner's existing five-second deadline.

Validation:

  • Real PostgreSQL17 pre-fix RED: removed callback still fired and final LISTEN registration remained (1a2a1b2b1c2c:1:1 instead of 1a2a1b2b2c:1:0).
  • A stable-identity-only intermediate fix passed that case but failed the pending-close case (first:2 instead of first:1).
  • Final-head 7a73d57d22c4227f3c970ff47ef57bdd63e6f394: both native ESM regressions passed (31.32s command), and the generated CJS pair passed (30.93s). Each run used a fresh real PostgreSQL17 fixture and the existing native runner with unchanged five-second scenario deadlines.
  • npm run build passed for CJS, Deno, and Cloudflare generators (15.43s). Generated snapshots were retained locally for proof; this PR follows the current upstream source-only commit convention.
  • Node syntax checks and whitespace checks passed. The focused proofs cover subscription ownership and cleanup; full upstream matrix and Deno runtime verification remain for the repository workflow.

Current-head workflow 37265016528 is awaiting maintainer approval and has not started any jobs. CI has not been claimed green.

Closes #1243

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

Successfully merging this pull request may close these issues.

Calling original unlisten after reconnect leaves its callback registered

1 participant