Skip to content

fix: ignore cancelled and replaced timer callbacks - #1273

Open
edsonsims wants to merge 1 commit into
porsager:masterfrom
edsonsims:fix/ignore-stale-timer-callbacks
Open

edsonsims wants to merge 1 commit into
porsager:masterfrom
edsonsims:fix/ignore-stale-timer-callbacks

Conversation

@edsonsims

Copy link
Copy Markdown

A connect-timeout callback delivered after cancellation can interrupt a ready query, fail after the socket has closed, or close a replacement connection. I added a generation and active-handle check to the shared timer helper so cancelled or replaced callbacks are inert. The active handle is cleared before invoking the handler, preserving rearming. Configured deadlines and public APIs are unchanged.

Refs #1270. The regression deliberately invokes captured callbacks after real local PostgreSQL startup, query, close and reconnect; it does not reproduce the reported Cloudflare timer-cancellation cause.

Validation with PostgreSQL 17.10:

  • Four permanent cases: three fail on the original source; all four pass with the fix, including a stalled protocol-cancellation connection that must still time out.
  • Full suites: 268 passes in ESM, generated CJS and Deno 2.1.4. ESM also passes on Node 24.19.0; the initial Node suites used 23.6.0.
  • ESLint and the generated builds pass. The patch includes canonical source and tests, following the current source-only contribution convention; unrelated pre-existing generated-file drift is excluded.

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.

1 participant