closeStream static method
Safe stream close with proper cleanup
Implementation
static Future<void> closeStream(
core_p2p_stream.P2PStream stream, {
String context = 'unknown',
}) async {
try {
if (!stream.isClosed) {
await stream.close();
_logger.fine('[$context] Stream closed successfully');
}
} catch (e) {
_logger.warning('[$context] Error closing stream: $e');
// Don't rethrow close errors
}
}