Skip to content

Dont crash on unsendable errors - #454

Merged
simolus3 merged 3 commits into
mainfrom
dont-crash-on-unsendable-errors
Aug 5, 2026
Merged

Dont crash on unsendable errors#454
simolus3 merged 3 commits into
mainfrom
dont-crash-on-unsendable-errors

Conversation

@simolus3

@simolus3 simolus3 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This fixes an issue where a backend connector throwing an exception that can't be sent across isolates causes the sync isolate to become stuck.

This can happen for errors that include an asynchronous primitive like Completer, which is the case for some errors thrown by the popular dio package for http requests. Sending these across ports throws, so PortCompleter.completeError would fail without ever sending the error to the sync isolate. That then causes the sync isolate to wait for a response indefinitely, blocking even disconnect() requests.

To fix this, we send a serialized toString() representation if the original error is unsendable. We also use capabilities (a special object that comes back unchanged when sent across isolates) and a weak map to recover the underlying error on the main isolate after it shows up as an uploadError / downloadError.

@simolus3
simolus3 marked this pull request as ready for review August 3, 2026 10:26
@simolus3
simolus3 requested a review from rkistner August 3, 2026 10:26
@simolus3
simolus3 force-pushed the dont-crash-on-unsendable-errors branch from 121035e to 76e99e8 Compare August 5, 2026 09:14
@simolus3
simolus3 requested a review from Chriztiaan August 5, 2026 10:54
@simolus3
simolus3 merged commit 774a9fa into main Aug 5, 2026
13 checks passed
@simolus3
simolus3 deleted the dont-crash-on-unsendable-errors branch August 5, 2026 12:00
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