Document sharing one DriftIsolate via IsolateNameServer #2095 - #3846
Document sharing one DriftIsolate via IsolateNameServer #2095#3846AzazelSensei wants to merge 2 commits 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
left a comment
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.
Drop the IsolateNameServer lookup-or-spawn snippet.
|
Dropped the IsolateNameServer snippet. The page now points at drift_flutter with shareAcrossIsolates, and at native.dart if someone still needs a custom handshake. |
|
I have merged your PR with some minor changes in 906593e. |
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