diff --git a/src/runtime/nodes/mqtt_shared.rs b/src/runtime/nodes/mqtt_shared.rs index 1ec1ff6..355ea34 100644 --- a/src/runtime/nodes/mqtt_shared.rs +++ b/src/runtime/nodes/mqtt_shared.rs @@ -230,8 +230,15 @@ impl Shared { } }; if teardown { - self.close.publish(self.client.as_ref()).await; - self.client.disconnect().await; + // Best-effort graceful close, time-bounded: if the broker is + // unreachable the client's request queue can be full, making + // `disconnect()` block — never let that stall teardown. + let _ = tokio::time::timeout(Duration::from_millis(500), async { + self.close.publish(self.client.as_ref()).await; + self.client.disconnect().await; + }) + .await; + // Always stop the driver so it can no longer reconnect or emit errors. if let Some(handle) = self.driver.lock().unwrap().take() { handle.abort(); }