Repository navigation
Conversation
okomarov
force-pushed
the
feat/async-dispose
branch
from
October 13, 2026 21:06
1b7293a to
e4b7bb6
Compare
The pool gets [Symbol.asyncDispose], which calls end() with no timeout, and reserved connections get [Symbol.dispose] and [Symbol.asyncDispose], which call release(). `await using sql = postgres()` and `using reserved = await sql.reserve()` can no longer leak the pool or a reservation. The pool method is set only on the top-level instance, never in Sql(), because Sql() also builds reserved and transaction handles and disposing those must not end the pool. Transaction handles, cursors, listen and subscribe are not disposable: begin() and for await already scope the first two. Both end() and release() are idempotent, so disposing after an explicit call is harmless. Each symbol is set only when the runtime defines it. The types bump @types/node to ^22 to match engines, since the symbols are declared there.
okomarov
force-pushed
the
feat/async-dispose
branch
from
October 13, 2026 21:06
e4b7bb6 to
76f8c5f
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #52.
[Symbol.asyncDispose]callingend(), on the top-level instance only: reserved and transaction handles are built by the sameSql()and must never end the pool (tested).[Symbol.dispose]and[Symbol.asyncDispose], both callingrelease().for await.sql.listen()andsql.subscribe()handles could map to unlisten and unsubscribe later.usingsyntax needs Node.js 24+; on Node 22 the methods can be called directly, and the syntax test passes without running.types/package.jsonmoves@types/nodeto^22to matchengines.Also carries 045695c (tracer compatibility), which is on local main but not yet pushed.