Document sharing one DriftIsolate via IsolateNameServer #2095 - #3846
Open
AzazelSensei wants to merge 1 commit into
Open
Document sharing one DriftIsolate via IsolateNameServer #2095#3846AzazelSensei wants to merge 1 commit into
AzazelSensei wants to merge 1 commit into
Conversation
Calling spawn from both the UI and a background worker creates two databases, so watch() on one side never sees the other side's writes. Fixes simolus3#2095
simolus3
reviewed
Aug 24, 2026
simolus3
left a comment
Owner
There was a problem hiding this comment.
Thanks for improving documentation on this!
Reading the snippet though, I wonder if we should instead add a link to drift_flutter sources as an inspiration instead of adding a standalone snippet. IsolateNameServer is a brittle API, and one needs to defend against cases like a hot restart where some isolates are restarted but the dead port is still registered in the isolate server (drift_flutter uses timeouts and pings for that).
But more importantly, IsolateNameServer only exists for Flutter and drift_flutter already does the right thing. So I suppose what the docs should suggest is a stronger focus on using drift_flutter instead of trying to wire up isolates manually.
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.
People hitting this usually spawn a DriftIsolate in the UI and again in a background service. Those are two databases, so
watch()in the foreground never sees the background writes.This adds that warning to the independent-isolates section, plus the lookup-or-spawn snippet using IsolateNameServer that you already confirmed on the issue. Flutter apps in the same engine can keep using
shareAcrossIsolates: trueinstead.Fixes #2095