iandis / isolated_worker

An isolated worker for Flutter (Isolate) and Web (Web Worker). Behaves almost the same as the compute function, except it is not a one-off worker.
MIT License
42 stars 11 forks source link

fix(isolated-worker-default): fix late init error on close #14

Closed iandis closed 2 years ago

iandis commented 2 years ago

This fixes #13

The error occurs on IsolatedWorkerImpl.close because the Isolate was not given a chance to warm up, making it throw LateInitializationError (because the Isolate object hasn't been created). This PR fixes it by awaiting the main SendPort to receive the child SendPort first so that the Isolate object can be created thus can be closed.