Skip to content

fix: clear the cancel_timeout timer once a canceled sql.batch settles - #1318

Merged
porsager merged 1 commit into
porsager:masterfrom
pcbeingused333:fix/batch-cancel-timer
Nov 11, 2026
Merged

porsager merged 1 commit into
porsager:masterfrom
pcbeingused333:fix/batch-cancel-timer

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #1317

Canceling a sql.batch left a cancel_timeout timer armed after the batch had already rejected with 57014, so the process stayed alive for cancel_timeout seconds (and sql.end() was not the cause). A plain query did not have the problem.

cancel() arms x.unanswered through expect(x). settle(x) calls answered(x) first, and answered only clears the timer when x.batch.query.settled. For a batch, the batch query is settled later in the same settle call (batched → query.reject), so the check always saw an unsettled query and the timer was never cleared. settle now calls answered(x) again for batch exchanges after settling.

tests/unit/cancel.js runs a canceled sql.batch against the simulated server and checks that no timers remain pending after the rejection. It fails before the change (1 pending timer at 5100 ms) and passes after. The unit suite and node tests/simulate.js (2000 seeds) pass.

This change was prepared, and the tests above were run, with the assistance of an AI coding tool.

The unanswered timer set by cancel() was cleared before the batch query
itself settled, so it stayed armed for cancel_timeout and kept the process alive.
@porsager

Copy link
Copy Markdown
Owner

Uh nice - thanks Alex...

@porsager
porsager merged commit 15c0748 into porsager:master Nov 11, 2026
37 checks passed
porsager added a commit that referenced this pull request Nov 11, 2026
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.

Cancelling sql.batch() keeps the process alive for cancel_timeout after sql.end()

2 participants