Skip to content

Fix sync isolate retry loop due to single-subscription stream#401

Merged
simolus3 merged 1 commit intomainfrom
fix-sync-isolate-retry-loop
Apr 13, 2026
Merged

Fix sync isolate retry loop due to single-subscription stream#401
simolus3 merged 1 commit intomainfrom
fix-sync-isolate-retry-loop

Conversation

@simolus3
Copy link
Copy Markdown
Contributor

@simolus3 simolus3 commented Apr 13, 2026

If, for whatever reason, we fail to instantiate a sync isolate on native platforms, we will retry automatically.

That's a sensible recovery strategy, but we use a single-subscription stream controller to notify the sync client about changed subscriptions. So on a reconnect, we'd attempt to subscribe again and get an immediate error because the stream has already been listened to.

This fixes the issue by using one controller per internal connect call. We can't use a broadcast stream controller since that would swallow events when no listeners are present, which is not what we want.

I've tested these changes manually by adding a random 70% crash chance in the sync isolate and started a demo app. We correctly respawn the isolate until that works now.

Closes #397.

@simolus3 simolus3 requested a review from LucDeCaf April 13, 2026 09:26
@simolus3 simolus3 merged commit fcea871 into main Apr 13, 2026
6 checks passed
@simolus3 simolus3 deleted the fix-sync-isolate-retry-loop branch April 13, 2026 09:39
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.

Sync isolate retry loop: "Stream has already been listened to" in connectInternal after rapid disconnectAndClear() + connect() cycle

2 participants