flush method

Future<void> flush()

Uploads buffered results now.

Overlapping calls are serialized, and errors are caught so a background timer cannot abort the test process (transport errors are handled inside and requeue the batch).

Implementation

Future<void> flush() {
  _flushChain = _flushChain.then((_) async {
    try {
      await _flushOnce();
      if (session.reportingEnabled && pendingCount > 0) {
        await _flushOnce();
      }
    } on Object catch (error, stack) {
      logError('Tracera: flush failed: ${formatFailureText(error, stack)}');
    }
  });
  return _flushChain;
}