closeFor method

  1. @override
Future<void> closeFor(
  1. RpcChannelCloseReason reason
)
override

Forwarded to the byte channel, so layers ABOVE this channel can report a peer fault too.

The transport validates inbound metadata against the security policy, and that violation is as deterministic as a framing one. Not forwarded, the transport could only reach close(), so a policy violation would read to the peer as retryable while a framing one does not.

Implementation

@override
Future<void> closeFor(RpcChannelCloseReason reason) async {
  if (_closed) return;
  // Flagged BEFORE the await, so nothing can be sent or decoded in the gap
  // while the byte channel is closing.
  _closed = true;
  try {
    await _channel.closeFor(reason);
  } catch (_) {}
  await _releaseAfterChannelClose();
}