fix: pubsub leak and shutdown seq

This commit is contained in:
adamdottv 2025-05-05 14:23:29 -05:00
commit 3cc08494a5
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
3 changed files with 173 additions and 19 deletions

View file

@ -123,12 +123,12 @@ to assist developers in writing, debugging, and understanding code directly from
// Cleanup function for when the program exits
cleanup := func() {
// Shutdown the app
app.Shutdown()
// Cancel subscriptions first
cancelSubs()
// Then shutdown the app
app.Shutdown()
// Then cancel TUI message handler
tuiCancel()
@ -188,6 +188,10 @@ func setupSubscriber[T any](
defer logging.RecoverPanic(fmt.Sprintf("subscription-%s", name), nil)
subCh := subscriber(ctx)
if subCh == nil {
logging.Warn("subscription channel is nil", "name", name)
return
}
for {
select {