WeKnora/cmd/desktop
Fei.Chen ec0ca46334
fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804)
* fix(server): signal shutdown raced Fatalf exit before ResourceCleaner ran

The signal goroutine closed the listener before calling server.Shutdown,
so Serve returned the raw accept error ('use of closed network connection')
instead of ErrServerClosed. The invoke error path then hit logger.Fatalf
(os.Exit(1)) in the same millisecond, killing the process before the
shutdown goroutine reached resourceCleaner.Cleanup. Every registered
cleaner — BrowserSkill daemon, sandbox reapers, IMService, AntsPool,
Langfuse — was skipped on every SIGTERM/SIGINT, leaking the shared bsk
daemon process and its temp home on each restart.

Two changes:
- Drop the manual listener.Close(): Shutdown closes all listeners as its
  first step, releasing the port just as fast without racing Serve.
- Give resourceCleaner.Cleanup its own fresh timeout context so a slow
  connection drain cannot leave Cleanup with an already-expired context,
  which made it skip every entry without running any.

* fix(server): keep signal cleanup inside one grace period

Desktop quit still closed the listener before Shutdown and returned
before ResourceCleaner finished, so Fatalf could skip every hook.
Share ShutdownTimeout between drain and cleanup, run BrowserSkill
first, and do not drop later hooks when the deadline expires.

* fix(server): satisfy errcheck and line-length lint

---------

Co-authored-by: vicfei <vicfei@users.noreply.github.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-28 23:37:36 +08:00
..
build fix: remove GPL converter and bundle third-party license sources 2026-09-08 15:19:10 +08:00
app.go fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804) 2026-09-28 23:37:36 +08:00
main.go fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804) 2026-09-28 23:37:36 +08:00
main_bindings.go feat: implement desktop app structure with API base URL handling and bindings for Wails integration 2026-04-11 18:51:16 +08:00
prefs.go feat(sandbox): run unpinned Lite sessions on the host OS sandbox (#3549) 2026-09-22 19:35:03 +08:00
prefs_test.go feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
proxy_test.go fix(desktop): pair the Lite browser against the local API listener (#3677) 2026-09-24 20:43:25 +08:00
signing_key.go feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
signing_key_test.go feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
update.go feat: implement automatic update checking and downloading functionality in the desktop app, enhancing user experience with seamless updates and corresponding UI settings 2026-04-11 18:51:16 +08:00
wails.json feat(sandbox): run unpinned Lite sessions on the host OS sandbox (#3549) 2026-09-22 19:35:03 +08:00