fix(tui): drop stale "updating DHT" overlay, bound shutdown wait

Pre-upgrade, `Gossip::shutdown()` synchronously published a "remove
self" entry to mainline DHT — that's where the TUI's "updating
DHT..." overlay came from, and it was genuinely slow. The
iroh-gossip-rendezvous 0.1 migration dropped that publish (entries
age out instead), but the shutdown flow didn't change: the overlay
still drew before shutdown ran, and the terminal was restored after.
So `q` would land the user on the misleading screen for as long as
`endpoint.close()` took to flush.

Restore the terminal the instant `q` is pressed, remove the overlay,
and bound `swarm.shutdown()` with a 2s timeout so a slow endpoint
close can't stall the process.
This commit is contained in:
swaits committed 2026-04-25 20:50:50 -06:00
1 parent b4cc826e74
commit b8e957fe33
2 files changed
+11 -30

No files matched your search

+10 -5
View File
@@ -1,7 +1,7 @@
use donglora_bridge::{config, gossip, radio, rate_limit, router, setup, tui};
use std::sync::Arc;
use std::time::Instant;
use std::time::{Duration, Instant};
use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
@@ -174,13 +174,18 @@ async fn main() -> Result<()> {
} else {
let terminal = tui::run(config_watch_rx, swarm.clone(), stats, log_rx, cancel.clone(), start_time);
cancel.cancel();
swarm.shutdown().await;
info!("donglora-bridge stopped");
// Restore the terminal first so the user's shell reappears the moment
// they hit `q`. iroh-gossip-rendezvous needs no synchronous DHT work
// on shutdown — entries age out — so the only remaining wait is
// `endpoint.close()` flushing in-flight connections. Bound it.
if let Ok(mut term) = terminal {
tui::restore_terminal(&mut term);
}
cancel.cancel();
if tokio::time::timeout(Duration::from_secs(2), swarm.shutdown()).await.is_err() {
warn!("graceful shutdown timed out — exiting anyway");
}
info!("donglora-bridge stopped");
return Ok(());
}