stopAll method

Future<void> stopAll()

Implementation

Future<void> stopAll() async {
  return await RunnerBenchmark.async('support_service', 'stopAll', () async {
    _stopRequested = true;
    Object? firstError;
    StackTrace? firstStackTrace;
    // Continue through every child when one process refuses cleanup. This
    // matters during suite timeout/interruption, where orphaned services can
    // affect the next run even though the first cleanup failure is reported.
    for (final service in _running.reversed.toList()) {
      try {
        await service.stop();
      } catch (error, stackTrace) {
        firstError ??= error;
        firstStackTrace ??= stackTrace;
      }
    }
    _running.clear();
    if (firstError != null) {
      Error.throwWithStackTrace(firstError, firstStackTrace!);
    }
  });
}