Skip to content

Close databases when they become unreferenced#149

Draft
simolus3 wants to merge 2 commits into
mainfrom
database-finalizer
Draft

Close databases when they become unreferenced#149
simolus3 wants to merge 2 commits into
mainfrom
database-finalizer

Conversation

@simolus3

@simolus3 simolus3 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

This is in an unpolished state, it doesn't make sense to merge this as-is. Even with this change, we're leaking workers in the PowerSync SDK (this might eventually be an improvement for sqlite_async users though).

Using the new WebSqlite.close() method from sqlite3_web version 0.9.0, this adds a finalizer that triggers when a WebSqlite instance becomes unused, when happens when:

  1. The open factory referencing it is unused, and
  2. All databases opened with it are unused.

In this case, we can call WebSqlite.close() from a finalizer to close dedicated workers.

This is a step towards powersync-ja/powersync.dart#427, unfortunately it didn't help for the PowerSync SDK.

Base automatically changed from update-sqlite-web to main June 10, 2026 14:32
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