Skip to content

Fix unrecoverable error when opening native db #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged

Conversation

simolus3
Copy link
Contributor

When opening a native database fails (for instance because the open factory is misconfigured and sends an invalid statement as a open pragma), we don't properly report this error to the client.

I would expect it to be reported through the initialize() future, but that actually misses the error. Also, the error is always reported as an unhandled exception which can easily crash the app.

This fixes these issues by:

  1. Making SqliteDatabaseImpl.initialized report SqliteConnectionImpl.initialized instead of an always-completed future.
  2. Avoid sending a close message if the isolate has crashed during open - we'll just get a guaranteed "already closed" error.
  3. In SqliteoConnectionImpl, make isInitialized point to _open. Previously, _open was unawaited which caused an unhandled exception if an exception was thrown there.
  4. In ParentPortClient, don't use sendPortFuture.then(). Attaching a first listener without an error handler used to also cause unhandled exceptions for reasons I'm not sure I understand. As an alternative we can set the SendPort field in the only place where initCompleter.complete is called.

@simolus3 simolus3 requested a review from stevensJourney May 27, 2025 21:12
@simolus3 simolus3 merged commit 277dfe0 into main May 28, 2025
6 checks passed
@simolus3 simolus3 mentioned this pull request May 28, 2025
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.

2 participants