shouldResetStream static method

bool shouldResetStream(
  1. YamuxException exception
)

Determines if a Yamux exception should trigger stream reset

Implementation

static bool shouldResetStream(YamuxException exception) {
  // Stream state exceptions usually mean the stream is already in a bad state
  if (exception is YamuxStreamStateException) {
    // If stream is already reset or closed, no need to reset again
    return !['reset', 'closed'].contains(exception.currentState);
  }

  // Protocol exceptions usually warrant a reset
  if (exception is YamuxStreamProtocolException) {
    return true;
  }

  // Timeout exceptions might warrant a reset
  if (exception is YamuxStreamTimeoutException) {
    return true;
  }

  // Session exceptions don't reset individual streams
  return false;
}