Skip to content

Keep query results alive through connection ownership#12

Merged
adsharma merged 4 commits intomainfrom
nodejs_conn_ownership
Apr 28, 2026
Merged

Keep query results alive through connection ownership#12
adsharma merged 4 commits intomainfrom
nodejs_conn_ownership

Conversation

@adsharma
Copy link
Copy Markdown
Contributor

Fixes: #8

NodeQueryResult now retains the native Connection instead of a Database handle. The result objects depend on database-owned state, and the native connection is the stable owner of that state even after the JS connection wrapper is closed.

This fixes the case where async query results are discarded and later finalized after conn.closeSync() and db.closeSync(). The finalizer can still destroy the MaterializedQueryResult safely because the retained connection keeps the backing database state alive.

Also add a regression test that mirrors the file-backed async query sequence from the external crash reproducer.

@adsharma adsharma force-pushed the nodejs_conn_ownership branch from a498eea to 2dee976 Compare April 28, 2026 03:31
@adsharma adsharma force-pushed the nodejs_conn_ownership branch from 10bb41d to febe857 Compare April 28, 2026 19:05
NodeQueryResult now retains the native Connection instead of a Database handle. The result objects depend on database-owned state, and the native connection is the stable owner of that state even after the JS connection wrapper is closed.

This fixes the case where async query results are discarded and later finalized after conn.closeSync() and db.closeSync(). The finalizer can still destroy the MaterializedQueryResult safely because the retained connection keeps the backing database state alive.

Also add a regression test that mirrors the file-backed async query sequence from the external crash reproducer.
@adsharma adsharma force-pushed the nodejs_conn_ownership branch from 48facbc to b8f0a3c Compare April 28, 2026 20:36
@adsharma adsharma merged commit f03d637 into main Apr 28, 2026
4 checks passed
@adsharma adsharma deleted the nodejs_conn_ownership branch April 28, 2026 21:28
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.

close() / closeSync() causes SIGSEGV or process hang after query execution on file-based databases

1 participant