zebra_network/peer/client.rs
1//! Handles outbound requests from our node to the network.
2
3use std::{
4 collections::HashSet,
5 future::Future,
6 iter,
7 pin::Pin,
8 sync::Arc,
9 task::{Context, Poll},
10};
11
12use futures::{
13 channel::{mpsc, oneshot},
14 future, ready,
15 stream::{Stream, StreamExt},
16 FutureExt,
17};
18use tokio::{sync::broadcast, task::JoinHandle};
19use tower::Service;
20
21use zebra_chain::diagnostic::task::CheckForPanics;
22
23use crate::{
24 peer::{
25 error::{AlreadyErrored, ErrorSlot, PeerError, SharedPeerError},
26 ConnectionInfo,
27 },
28 peer_set::InventoryChange,
29 protocol::{
30 external::InventoryHash,
31 internal::{Request, Response},
32 },
33 BoxError, PeerSocketAddr,
34};
35
36#[cfg(any(test, feature = "proptest-impl"))]
37pub mod tests;
38
39/// The "client" duplex half of a peer connection.
40pub struct Client {
41 /// The metadata for the connected peer `service`.
42 pub connection_info: Arc<ConnectionInfo>,
43
44 /// Used to shut down the corresponding heartbeat.
45 /// This is always Some except when we take it on drop.
46 pub(crate) shutdown_tx: Option<oneshot::Sender<CancelHeartbeatTask>>,
47
48 /// Used to send [`Request`]s to the remote peer.
49 pub(crate) server_tx: mpsc::Sender<ClientRequest>,
50
51 /// Sends block adverts without waiting for an outstanding request's response.
52 pub(crate) block_advert_tx: tokio::sync::mpsc::Sender<crate::peer_set::BlockAdvert>,
53
54 /// Used to register missing inventory in client [`Response`]s,
55 /// so that the peer set can route retries to other clients.
56 pub(crate) inv_collector: broadcast::Sender<InventoryChange>,
57
58 /// A slot for an error shared between the Connection and the Client that uses it.
59 ///
60 /// `None` unless the connection or client have errored.
61 pub(crate) error_slot: ErrorSlot,
62
63 /// A handle to the task responsible for connecting to the peer.
64 pub(crate) connection_task: JoinHandle<()>,
65
66 /// A handle to the task responsible for sending periodic heartbeats.
67 pub(crate) heartbeat_task: JoinHandle<Result<(), BoxError>>,
68}
69
70/// A signal sent by the [`Client`] half of a peer connection,
71/// to cancel a [`Client`]'s heartbeat task.
72///
73/// When it receives this signal, the heartbeat task exits.
74#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
75pub struct CancelHeartbeatTask;
76
77/// A message from the `peer::Client` to the `peer::Server`.
78#[derive(Debug)]
79pub(crate) struct ClientRequest {
80 /// The actual network request for the peer.
81 pub request: Request,
82
83 /// The response `Message` channel, included because `peer::Client::call`
84 /// returns a future that may be moved around before it resolves.
85 pub tx: oneshot::Sender<Result<Response, SharedPeerError>>,
86
87 /// Used to register missing inventory in responses on `tx`,
88 /// so that the peer set can route retries to other clients.
89 pub inv_collector: Option<broadcast::Sender<InventoryChange>>,
90
91 /// The peer address for registering missing inventory.
92 ///
93 /// TODO: replace this with `ConnectedAddr`?
94 pub transient_addr: Option<PeerSocketAddr>,
95
96 /// The tracing context for the request, so that work the connection task does
97 /// processing messages in the context of this request will have correct context.
98 pub span: tracing::Span,
99}
100
101/// A receiver for the `peer::Server`, which wraps a `mpsc::Receiver`,
102/// converting `ClientRequest`s into `InProgressClientRequest`s.
103#[derive(Debug)]
104pub(super) struct ClientRequestReceiver {
105 /// The inner receiver
106 inner: mpsc::Receiver<ClientRequest>,
107}
108
109/// A message from the `peer::Client` to the `peer::Server`,
110/// after it has been received by the `peer::Server`.
111#[derive(Debug)]
112#[must_use = "tx.send() must be called before drop"]
113pub(super) struct InProgressClientRequest {
114 /// The actual request.
115 pub request: Request,
116
117 /// The return message channel, included because `peer::Client::call` returns a
118 /// future that may be moved around before it resolves.
119 ///
120 /// INVARIANT: `tx.send()` must be called before dropping `tx`.
121 ///
122 /// JUSTIFICATION: the `peer::Client` translates `Request`s into
123 /// `ClientRequest`s, which it sends to a background task. If the send is
124 /// `Ok(())`, it will assume that it is safe to unconditionally poll the
125 /// `Receiver` tied to the `Sender` used to create the `ClientRequest`.
126 ///
127 /// We also take advantage of this invariant to route inventory requests
128 /// away from peers that did not respond with that inventory.
129 ///
130 /// We enforce this invariant via the type system, by converting
131 /// `ClientRequest`s to `InProgressClientRequest`s when they are received by
132 /// the background task. These conversions are implemented by
133 /// `ClientRequestReceiver`.
134 pub tx: MustUseClientResponseSender,
135
136 /// The tracing context for the request, so that work the connection task does
137 /// processing messages in the context of this request will have correct context.
138 pub span: tracing::Span,
139}
140
141/// A `oneshot::Sender` for client responses, that must be used by calling `send()`.
142/// Also handles forwarding missing inventory to the inventory registry.
143///
144/// Panics on drop if `tx` has not been used or canceled.
145/// Panics if `tx.send()` is used more than once.
146#[derive(Debug)]
147#[must_use = "tx.send() must be called before drop"]
148pub(super) struct MustUseClientResponseSender {
149 /// The sender for the oneshot client response channel.
150 ///
151 /// `None` if `tx.send()` has been used.
152 pub tx: Option<oneshot::Sender<Result<Response, SharedPeerError>>>,
153
154 /// Forwards missing inventory in the response to the inventory collector.
155 ///
156 /// Boxed to reduce the size of containing structures.
157 pub missing_inv: Option<Box<MissingInventoryCollector>>,
158}
159
160/// Forwards missing inventory in the response to the inventory registry.
161#[derive(Debug)]
162pub(super) struct MissingInventoryCollector {
163 /// A clone of the original request, if it is an inventory request.
164 ///
165 /// This struct is only ever created with inventory requests.
166 request: Request,
167
168 /// Used to register missing inventory from responses,
169 /// so that the peer set can route retries to other clients.
170 collector: broadcast::Sender<InventoryChange>,
171
172 /// The peer address for registering missing inventory.
173 transient_addr: PeerSocketAddr,
174}
175
176impl std::fmt::Debug for Client {
177 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
178 // skip the channels, they don't tell us anything useful
179 f.debug_struct("Client")
180 .field("connection_info", &self.connection_info)
181 .field("error_slot", &self.error_slot)
182 .field("connection_task", &self.connection_task)
183 .field("heartbeat_task", &self.heartbeat_task)
184 .finish()
185 }
186}
187
188impl From<ClientRequest> for InProgressClientRequest {
189 fn from(client_request: ClientRequest) -> Self {
190 let ClientRequest {
191 request,
192 tx,
193 inv_collector,
194 transient_addr,
195 span,
196 } = client_request;
197
198 let tx = MustUseClientResponseSender::new(tx, &request, inv_collector, transient_addr);
199
200 InProgressClientRequest { request, tx, span }
201 }
202}
203
204impl ClientRequestReceiver {
205 /// Forwards to `inner.close()`.
206 pub fn close(&mut self) {
207 self.inner.close()
208 }
209
210 /// Closes `inner`, then gets the next pending [`Request`].
211 ///
212 /// Closing the channel ensures that:
213 /// - the request stream terminates, and
214 /// - task notifications are not required.
215 pub fn close_and_flush_next(&mut self) -> Option<InProgressClientRequest> {
216 self.inner.close();
217
218 // # Correctness
219 //
220 // The request stream terminates, because the sender is closed,
221 // and the channel has a limited capacity.
222 // Task notifications are not required, because the sender is closed.
223 //
224 // Despite what its documentation says, we've seen futures::channel::mpsc::Receiver::try_recv()
225 // return an error after the channel is closed.
226 self.inner.try_recv().ok().map(Into::into)
227 }
228}
229
230impl Stream for ClientRequestReceiver {
231 type Item = InProgressClientRequest;
232
233 /// Converts the successful result of `inner.poll_next()` to an
234 /// `InProgressClientRequest`.
235 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
236 match self.inner.poll_next_unpin(cx) {
237 Poll::Ready(client_request) => Poll::Ready(client_request.map(Into::into)),
238 // CORRECTNESS
239 //
240 // The current task must be scheduled for wakeup every time we
241 // return `Poll::Pending`.
242 //
243 // inner.poll_next_unpin` schedules this task for wakeup when
244 // there are new items available in the inner stream.
245 Poll::Pending => Poll::Pending,
246 }
247 }
248
249 /// Returns `inner.size_hint()`
250 fn size_hint(&self) -> (usize, Option<usize>) {
251 self.inner.size_hint()
252 }
253}
254
255impl From<mpsc::Receiver<ClientRequest>> for ClientRequestReceiver {
256 fn from(rx: mpsc::Receiver<ClientRequest>) -> Self {
257 ClientRequestReceiver { inner: rx }
258 }
259}
260
261impl MustUseClientResponseSender {
262 /// Returns a newly created client response sender for `tx`.
263 ///
264 /// If `request` or the response contains missing inventory,
265 /// it is forwarded to the `inv_collector`, for the peer at `transient_addr`.
266 pub fn new(
267 tx: oneshot::Sender<Result<Response, SharedPeerError>>,
268 request: &Request,
269 inv_collector: Option<broadcast::Sender<InventoryChange>>,
270 transient_addr: Option<PeerSocketAddr>,
271 ) -> Self {
272 Self {
273 tx: Some(tx),
274 missing_inv: MissingInventoryCollector::new(request, inv_collector, transient_addr),
275 }
276 }
277
278 /// Forwards `response` to `tx.send()`, and missing inventory to `inv_collector`,
279 /// and marks this sender as used.
280 ///
281 /// Panics if `tx.send()` is used more than once.
282 pub fn send(
283 mut self,
284 response: Result<Response, SharedPeerError>,
285 ) -> Result<(), Result<Response, SharedPeerError>> {
286 // Forward any missing inventory to the registry.
287 if let Some(missing_inv) = self.missing_inv.take() {
288 missing_inv.send(&response);
289 }
290
291 // Forward the response to the internal requester.
292 self.tx
293 .take()
294 .unwrap_or_else(|| {
295 panic!(
296 "multiple uses of response sender: response must be sent exactly once: {self:?}"
297 )
298 })
299 .send(response)
300 }
301
302 /// Returns `tx.cancellation()`.
303 ///
304 /// Panics if `tx.send()` has previously been used.
305 pub fn cancellation(&mut self) -> oneshot::Cancellation<'_, Result<Response, SharedPeerError>> {
306 self.tx
307 .as_mut()
308 .map(|tx| tx.cancellation())
309 .unwrap_or_else( || {
310 panic!("called cancellation() after using oneshot sender: oneshot must be used exactly once")
311 })
312 }
313
314 /// Returns `tx.is_canceled()`.
315 ///
316 /// Panics if `tx.send()` has previously been used.
317 pub fn is_canceled(&self) -> bool {
318 self.tx
319 .as_ref()
320 .map(|tx| tx.is_canceled())
321 .unwrap_or_else(
322 || panic!("called is_canceled() after using oneshot sender: oneshot must be used exactly once: {self:?}"))
323 }
324}
325
326impl Drop for MustUseClientResponseSender {
327 #[instrument(skip(self))]
328 fn drop(&mut self) {
329 // we don't panic if we are shutting down anyway
330 if !zebra_chain::shutdown::is_shutting_down() {
331 // is_canceled() will not panic, because we check is_none() first
332 assert!(
333 self.tx.is_none() || self.is_canceled(),
334 "unused client response sender: oneshot must be used or canceled: {self:?}"
335 );
336 }
337 }
338}
339
340impl MissingInventoryCollector {
341 /// Returns a newly created missing inventory collector, if needed.
342 ///
343 /// If `request` or the response contains missing inventory,
344 /// it is forwarded to the `inv_collector`, for the peer at `transient_addr`.
345 pub fn new(
346 request: &Request,
347 inv_collector: Option<broadcast::Sender<InventoryChange>>,
348 transient_addr: Option<PeerSocketAddr>,
349 ) -> Option<Box<MissingInventoryCollector>> {
350 if !request.is_inventory_download() {
351 return None;
352 }
353
354 if let (Some(inv_collector), Some(transient_addr)) = (inv_collector, transient_addr) {
355 Some(Box::new(MissingInventoryCollector {
356 request: request.clone(),
357 collector: inv_collector,
358 transient_addr,
359 }))
360 } else {
361 None
362 }
363 }
364
365 /// Forwards explicitly observed missing inventory to the registry.
366 ///
367 /// Only explicit `notfound` responses update the registry. Transport
368 /// failures and timeouts do not prove the peer lacks the inventory,
369 /// so they are not forwarded (prevents registry poisoning under
370 /// high sync concurrency).
371 pub fn send(self, response: &Result<Response, SharedPeerError>) {
372 let missing_inv: HashSet<InventoryHash> = match (self.request, response) {
373 // Missing block hashes from partial responses.
374 (_, Ok(Response::Blocks(block_statuses))) => block_statuses
375 .iter()
376 .filter_map(|b| b.missing())
377 .map(InventoryHash::Block)
378 .collect(),
379
380 // Missing transaction IDs from partial responses.
381 (_, Ok(Response::Transactions(tx_statuses))) => tx_statuses
382 .iter()
383 .filter_map(|tx| tx.missing())
384 .map(|tx| tx.into())
385 .collect(),
386
387 // Other response types never contain missing inventory.
388 (_, Ok(_)) => iter::empty().collect(),
389
390 // Registry-generated errors are already tracked — don't re-forward.
391 (_, Err(e)) if e.inner_debug().contains("NotFoundRegistry") => iter::empty().collect(),
392
393 // Only mark inventory as missing for explicit notfound responses.
394 // Transport failures (timeouts, dropped connections) do not prove
395 // the peer lacks the inventory — they only prove the request failed.
396 // Treating them as missing poisons the routing registry under high
397 // sync concurrency.
398 (ref request, Err(e)) if e.inner_debug().contains("NotFoundResponse") => request
399 .block_hash_inventory()
400 .into_iter()
401 .map(InventoryHash::Block)
402 .chain(
403 request
404 .transaction_id_inventory()
405 .into_iter()
406 .map(InventoryHash::from),
407 )
408 .collect(),
409
410 // All other errors (timeouts, drops, overload): don't poison.
411 (_, Err(_)) => iter::empty().collect(),
412 };
413
414 if let Some(missing_inv) =
415 InventoryChange::new_missing_multi(missing_inv.iter(), self.transient_addr)
416 {
417 // if all the receivers are closed, assume we're in tests or an isolated connection
418 let _ = self.collector.send(missing_inv);
419 }
420 }
421}
422
423impl Client {
424 /// Check if this connection's heartbeat task has exited.
425 ///
426 /// Returns an error if the heartbeat task exited. Otherwise, schedules the client task for
427 /// wakeup when the heartbeat task finishes, or the channel closes, and returns `Pending`.
428 ///
429 /// # Panics
430 ///
431 /// If the heartbeat task panicked.
432 #[allow(clippy::unwrap_in_result)]
433 fn poll_heartbeat(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), SharedPeerError>> {
434 let is_canceled = self
435 .shutdown_tx
436 .as_mut()
437 .expect("only taken on drop")
438 .poll_canceled(cx)
439 .is_ready();
440
441 let result = match self.heartbeat_task.poll_unpin(cx) {
442 Poll::Pending => {
443 // The heartbeat task returns `Pending` while it continues to run.
444 // But if it has dropped its receiver, it is shutting down, and we should also shut down.
445 if is_canceled {
446 self.set_task_exited_error(
447 "heartbeat",
448 PeerError::HeartbeatTaskExited("Task was cancelled".to_string()),
449 )
450 } else {
451 // Heartbeat task is still running.
452 return Poll::Pending;
453 }
454 }
455 Poll::Ready(Ok(Ok(_))) => {
456 // Heartbeat task stopped unexpectedly, without panic or error.
457 self.set_task_exited_error(
458 "heartbeat",
459 PeerError::HeartbeatTaskExited(
460 "Heartbeat task stopped unexpectedly".to_string(),
461 ),
462 )
463 }
464 Poll::Ready(Ok(Err(error))) => {
465 // Heartbeat task stopped unexpectedly, with error.
466 self.set_task_exited_error(
467 "heartbeat",
468 PeerError::HeartbeatTaskExited(error.to_string()),
469 )
470 }
471 Poll::Ready(Err(error)) => {
472 // Heartbeat task panicked.
473 let error = error.panic_if_task_has_panicked();
474
475 // Heartbeat task was cancelled.
476 if error.is_cancelled() {
477 self.set_task_exited_error(
478 "heartbeat",
479 PeerError::HeartbeatTaskExited("Task was cancelled".to_string()),
480 )
481 }
482 // Heartbeat task stopped with another kind of task error.
483 else {
484 self.set_task_exited_error(
485 "heartbeat",
486 PeerError::HeartbeatTaskExited(error.to_string()),
487 )
488 }
489 }
490 };
491
492 Poll::Ready(result)
493 }
494
495 /// Check if the connection's request/response task has exited.
496 ///
497 /// Returns an error if the connection task exited. Otherwise, schedules the client task for
498 /// wakeup when the connection task finishes, and returns `Pending`.
499 ///
500 /// # Panics
501 ///
502 /// If the connection task panicked.
503 fn poll_connection(&mut self, context: &mut Context<'_>) -> Poll<Result<(), SharedPeerError>> {
504 // Return `Pending` if the connection task is still running.
505 let result = match ready!(self.connection_task.poll_unpin(context)) {
506 Ok(()) => {
507 // Connection task stopped unexpectedly, without panicking.
508 self.set_task_exited_error("connection", PeerError::ConnectionTaskExited)
509 }
510 Err(error) => {
511 // Connection task panicked or was cancelled.
512 let _ = error.panic_if_task_has_panicked();
513
514 // Any unexpected termination of the connection task is reported as ConnectionTaskExited.
515 self.set_task_exited_error("connection", PeerError::ConnectionTaskExited)
516 }
517 };
518
519 Poll::Ready(result)
520 }
521
522 /// Properly update the error slot after a background task has unexpectedly stopped.
523 fn set_task_exited_error(
524 &mut self,
525 task_name: &str,
526 error: PeerError,
527 ) -> Result<(), SharedPeerError> {
528 // Make sure there is an error in the slot
529 let task_error = SharedPeerError::from(error);
530 let original_error = self.error_slot.try_update_error(task_error.clone());
531 debug!(
532 ?original_error,
533 latest_error = ?task_error,
534 "client {} task exited", task_name
535 );
536
537 if let Err(AlreadyErrored { original_error }) = original_error {
538 Err(original_error)
539 } else {
540 Err(task_error)
541 }
542 }
543
544 /// Poll for space in the shared request sender channel.
545 ///
546 /// Returns an error if the sender channel is closed. If there is no space in the channel,
547 /// returns `Pending`, and schedules the task for wakeup when there is space available.
548 fn poll_request(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), SharedPeerError>> {
549 let server_result = ready!(self.server_tx.poll_ready(cx));
550 if server_result.is_err() {
551 Poll::Ready(Err(self
552 .error_slot
553 .try_get_error()
554 .unwrap_or_else(|| PeerError::ConnectionTaskExited.into())))
555 } else if let Some(error) = self.error_slot.try_get_error() {
556 Poll::Ready(Err(error))
557 } else {
558 Poll::Ready(Ok(()))
559 }
560 }
561
562 /// Poll for space in the shared request sender channel, and for errors in the connection tasks.
563 ///
564 /// Returns an error if the sender channel is closed, or the heartbeat or connection tasks have
565 /// terminated. If there is no space in the channel, returns `Pending`, and schedules the task
566 /// for wakeup when there is space available, or one of the tasks terminates.
567 fn poll_client(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), SharedPeerError>> {
568 // # Correctness
569 //
570 // The current task must be scheduled for wakeup every time we return
571 // `Poll::Pending`.
572 //
573 // `poll_heartbeat()` and `poll_connection()` schedule the client task for wakeup
574 // if either task exits, or if the heartbeat task drops the cancel handle.
575 //
576 //`ready!` returns `Poll::Pending` when `server_tx` is unready, and
577 // schedules this task for wakeup.
578 //
579 // It's ok to exit early and skip wakeups when there is an error, because the connection
580 // and its tasks are shut down immediately on error.
581
582 let _heartbeat_pending: Poll<()> = self.poll_heartbeat(cx)?;
583 let _connection_pending: Poll<()> = self.poll_connection(cx)?;
584
585 // We're only pending if the sender channel is full.
586 self.poll_request(cx)
587 }
588
589 /// Shut down the resources held by the client half of this peer connection.
590 ///
591 /// Stops further requests to the remote peer, and stops the heartbeat task.
592 fn shutdown(&mut self) {
593 // Prevent any senders from sending more messages to this peer.
594 self.server_tx.close_channel();
595
596 // Ask the heartbeat task to stop.
597 if let Some(shutdown_tx) = self.shutdown_tx.take() {
598 let _ = shutdown_tx.send(CancelHeartbeatTask);
599 }
600
601 // Force the connection and heartbeat tasks to stop.
602 self.connection_task.abort();
603 self.heartbeat_task.abort();
604 }
605}
606
607impl Service<Request> for Client {
608 type Response = Response;
609 type Error = SharedPeerError;
610 type Future =
611 Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
612
613 fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
614 // # Correctness
615 //
616 // The current task must be scheduled for wakeup every time we return
617 // `Poll::Pending`.
618 //
619 // `poll_client()` schedules the client task for wakeup if the sender channel has space,
620 // either connection task exits, or if the heartbeat task drops the cancel handle.
621
622 // Check all the tasks and channels.
623 //
624 //`ready!` returns `Poll::Pending` when `server_tx` is unready, and
625 // schedules this task for wakeup.
626 let result = ready!(self.poll_client(cx));
627
628 // Shut down the client and connection if there is an error.
629 if let Err(error) = result {
630 self.shutdown();
631
632 Poll::Ready(Err(error))
633 } else {
634 Poll::Ready(Ok(()))
635 }
636 }
637
638 fn call(&mut self, request: Request) -> Self::Future {
639 let (tx, rx) = oneshot::channel();
640 // get the current Span to propagate it to the peer connection task.
641 // this allows the peer connection to enter the correct tracing context
642 // when it's handling messages in the context of processing this
643 // request.
644 let span = tracing::Span::current();
645
646 match self.server_tx.try_send(ClientRequest {
647 request,
648 tx,
649 inv_collector: Some(self.inv_collector.clone()),
650 transient_addr: self.connection_info.connected_addr.get_transient_addr(),
651 span,
652 }) {
653 Err(e) => {
654 if e.is_disconnected() {
655 let peer_error = self
656 .error_slot
657 .try_get_error()
658 .unwrap_or_else(|| PeerError::ConnectionTaskExited.into());
659
660 let ClientRequest { tx, .. } = e.into_inner();
661 let _ = tx.send(Err(peer_error.clone()));
662
663 future::ready(Err(peer_error)).boxed()
664 } else {
665 // sending fails when there's not enough
666 // channel space, but we called poll_ready
667 panic!("called call without poll_ready");
668 }
669 }
670 Ok(()) => {
671 // The receiver end of the oneshot is itself a future.
672 rx.map(|oneshot_recv_result| {
673 // The ClientRequest oneshot sender should not be dropped before sending a
674 // response. But sometimes that happens during process or connection shutdown.
675 // So we just return a generic error here.
676 match oneshot_recv_result {
677 Ok(result) => result,
678 Err(oneshot::Canceled) => Err(PeerError::ConnectionDropped.into()),
679 }
680 })
681 .boxed()
682 }
683 }
684 }
685}
686
687impl Drop for Client {
688 fn drop(&mut self) {
689 // Make sure there is an error in the slot
690 let drop_error: SharedPeerError = PeerError::ClientDropped.into();
691 let original_error = self.error_slot.try_update_error(drop_error.clone());
692 debug!(
693 ?original_error,
694 latest_error = ?drop_error,
695 "client struct dropped"
696 );
697
698 self.shutdown();
699 }
700}