Skip to content

Commit

Permalink
fix(tui): simplify application deregistration logic in Subscriber
Browse files Browse the repository at this point in the history
the old way could occasionally see an application not get properly deregistered after closing
  • Loading branch information
AnthonyMichaelTDM committed Jan 23, 2025
1 parent 2611b47 commit 91411d7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,17 @@ impl Subscriber {
.register_application(Context::current(), application_addr.port())
.await??;

tokio::spawn(async move {
if handler.await == Err(future::Aborted) {
let _ = daemon
.clone()
.unregister_application(Context::current(), application_addr.port())
.await;
}
});
tokio::spawn(handler);

let interrupted = interrupt_rx.recv().await;

abort_handle.abort();

let _ = daemon
.clone()
.unregister_application(Context::current(), application_addr.port())
.await;

Ok(interrupted?)
}
}
Expand Down

0 comments on commit 91411d7

Please sign in to comment.