Skip to content

fix(ext/node): DatabaseSync garbage collection invalidating associated resources#31737

Merged
dsherret merged 10 commits intodenoland:mainfrom
ayuusweetfish:sqlite-gc
Jan 10, 2026
Merged

fix(ext/node): DatabaseSync garbage collection invalidating associated resources#31737
dsherret merged 10 commits intodenoland:mainfrom
ayuusweetfish:sqlite-gc

Conversation

@ayuusweetfish
Copy link
Contributor

@ayuusweetfish ayuusweetfish commented Dec 30, 2025

Resolves #31732, following the proposed fix there.

Note: when the database is explicitly close()d, the associated resources (StatementSync and Session) are already dropped due to Database::close() taking away these references. Hence no additional change is needed to invalidate them; we simply check whether they are None.

stmt.set(None);

let _ = self.conn.borrow_mut().take();

A remaining question is how we should distinguish between the error codes StatementFinalized and AlreadyClosed. Apparently, statements are "finalized" (inner set to None) only when the database is closed, so it seems that these two codes are currently equivalent. The added test case expects two different error messages, but it does not seem very natural.

@CLAassistant
Copy link

CLAassistant commented Dec 30, 2025

CLA assistant check
All committers have signed the CLA.

@ayuusweetfish ayuusweetfish marked this pull request as ready for review December 31, 2025 05:35
…enoland#31722)

SQLite numbered positional parameters (?1, ?2, ?NNN) were incorrectly
treated as named parameters and skipped during binding, causing a
"column index out of range" error. This fix updates the parameter
binding logic to recognize that parameters whose names start with '?'
are positional and should be bound in order, just like anonymous
parameters (?).

Fixes denoland#31719

(cherry picked from commit d08d790)
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dsherret dsherret changed the title fix(ext/node): Fix DatabaseSync garbage collection invalidating associated resources fix(ext/node): DatabaseSync garbage collection invalidating associated resources Jan 9, 2026
@dsherret dsherret enabled auto-merge (squash) January 9, 2026 17:24
@dsherret dsherret merged commit 466ab12 into denoland:main Jan 10, 2026
19 checks passed
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.

node:sqlite: Connection lost if DatabaseSync is garbage-collected

5 participants