Recipes

Connect a child isolate

Route child-isolate error-port messages into the application-owned manager with explicit listener ownership.

v0.1.0-dev.1Advancedark_error_manager

Connect a child isolate

Errors from a child isolate do not automatically reach the root Zone or Flutter's PlatformDispatcher.onError. The owner of the isolate must attach an error-port bridge.

dart
final Isolate worker = await Isolate.spawn(
  startWorker,
  input,
  paused: true,
);

final IsolateErrorManagerBinding errorBinding =
    IsolateErrorManagerBinding(
  isolate: worker,
  manager: manager,
)..attach();

worker.resume(worker.pauseCapability!);

Creating the worker paused prevents it from failing before the listener is attached. The binding records ErrorCaptureSource.isolate and forwards the remote error and stack trace to the same ordered pipeline.

Detach the binding before transferring isolate ownership, killing the worker, or closing the manager. One owner should control the worker and its error listener together.

ARKTELOS

Purpose-built engineering systems for software that has to hold.