fix(hub): stop launching system updaters after manager shutdown (#1950) (#1951)

The staggered Initialize goroutine kept calling AddSystem after the hub
had been torn down, which spawned StartUpdater goroutines that later
dereferenced a nil DB inside PocketBase. Track a manager-level context
that RemoveAllSystems cancels, abort the staggered loop on shutdown,
and refuse AddSystem once the manager is stopped.
This commit is contained in:
Yvan Wang
2026-08-18 01:59:42 +08:00
committed by GitHub
parent c1c1cd1bcb
commit 63959694de
3 changed files with 42 additions and 1 deletions

View File

@@ -111,6 +111,11 @@ func (sm *SystemManager) SetSystemStatusInDB(systemID string, status string) boo
// TESTING ONLY: RemoveAllSystems removes all systems from the store
func (sm *SystemManager) RemoveAllSystems() {
// Signal shutdown first so any in-flight Initialize staggered-start goroutine
// stops adding new systems against a hub that is about to be torn down. See #1950.
if sm.cancel != nil {
sm.cancel()
}
for _, system := range sm.systems.GetAll() {
sm.RemoveSystem(system.Id)
}