From 9c62bf0152afcdab4d90531efa12e49133fc8010 Mon Sep 17 00:00:00 2001 From: rouggy Date: Tue, 21 Jul 2026 10:15:02 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20cleanly=20stop=20CAT=20(and=20release=20?= =?UTF-8?q?relay=20handles)=20on=20shutdown=20=E2=80=94=20FlexRadio=20kept?= =?UTF-8?q?=20our=20API=20client=20registered,=20making=20the=20next=20lau?= =?UTF-8?q?nch=20take=20~30s=20to=20reconnect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app.go b/app.go index c42b879..7892297 100644 --- a/app.go +++ b/app.go @@ -1193,8 +1193,15 @@ func (a *App) runShutdownTasks(ctx context.Context, steps []shutdownStep) { a.emitShutdownEvent("shutdown:update", steps) } a.emitShutdownEvent("shutdown:done", steps) - // Give the UI a moment to show the "done" state before we yank the - // window away. 600ms feels purposeful without being annoying. + // Cleanly tear down hardware links before quitting. Especially the CAT + // backend: a FlexRadio keeps our API client registered until it notices the + // TCP is gone, and just letting the process exit left the slot stale — the + // NEXT launch then spent ~30s retrying the connect before the radio freed it. + // cat.Stop() closes the socket with a proper FIN so the radio drops us at once. + if a.cat != nil { + a.cat.Stop() + } + a.closeRelayDrivers() // release FTDI/serial relay handles for the next launch time.Sleep(600 * time.Millisecond) wruntime.Quit(ctx) }