debugTerminateWorkerForTesting method

  1. @visibleForTesting
Future<void> debugTerminateWorkerForTesting({
  1. bool expected = false,
  2. DebugTerminatePoint? at,
})

Terminates the supervised control isolate without touching native state — immediately when at is omitted, or armed at that exact lifecycle injection point (see DebugTerminatePoint). The caller-isolate rescue path must quarantine any matching runtime. expected applies only to an immediate termination.

Implementation

@visibleForTesting
Future<void> debugTerminateWorkerForTesting({
  bool expected = false,
  // Deliberate: this wrapper is itself test-only; the enum's annotation
  // still guards direct production arming.
  // ignore: invalid_use_of_visible_for_testing_member
  DebugTerminatePoint? at,
}) async {
  _requireInitialized();
  final worker = await _workerForCall();
  await worker.debugWaitUntilReady();
  if (at == null) {
    worker.debugTerminate(expected: expected);
  } else {
    worker.debugArmTermination(at);
  }
}