Skip to content

fix(daemon): register echo + IPC bind accept loops on bgWG (PILOT-88)#407

Merged
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-88-20260721-103843
Jul 22, 2026
Merged

fix(daemon): register echo + IPC bind accept loops on bgWG (PILOT-88)#407
TeoSlayer merged 1 commit into
mainfrom
openclaw/pilot-88-20260721-103843

Conversation

@matthew-pilot

Copy link
Copy Markdown
Collaborator

What

Two long-lived fire-and-forget goroutines — the echo service accept loop (startEchoService) and the IPC bind accept pusher (handleBind) — were spawned without registering on d.bgWG. During graceful shutdown, these goroutines check stopCh or rely on AcceptCh close to exit, but bgWG.Wait() in doStop had no visibility into them; only the 5s wall-clock timeout protected against shutdown races with shared state.

Fix

Added d.bgWG.Add(1) / defer d.bgWG.Done() around both accept loops so doStop tracks them alongside the existing 14 tracked background goroutines.

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • go test -run TestStart ./pkg/daemon/ — passes
  • TestStartEchoServiceBGWaitGroupTracksAcceptLoop — new test verifying close(stopCh) drains bgWG within 2s

Closes https://vulturelabs.atlassian.net/browse/PILOT-88

Two long-lived fire-and-forget goroutines — the echo service accept loop
(startEchoService) and the IPC bind accept pusher (handleBind) — were
spawned without registering on d.bgWG. During graceful shutdown, these
goroutines check stopCh or rely on AcceptCh close to exit, but
bgWG.Wait() in doStop had no visibility into them; only the 5s wall-clock
timeout protected against shutdown races with shared state.

Fix: add d.bgWG.Add(1) / defer d.bgWG.Done() around both accept loops
so doStop tracks them alongside the existing 14 tracked background
goroutines (routeLoop, trustRepublishLoop, etc.).

Test: TestStartEchoServiceBGWaitGroupTracksAcceptLoop verifies that
close(stopCh) drains bgWG within 2s.

Closes PILOT-88
@matthew-pilot
matthew-pilot requested a review from TeoSlayer as a code owner July 21, 2026 10:39
@TeoSlayer
TeoSlayer merged commit 153602a into main Jul 22, 2026
14 checks passed
@matthew-pilot
matthew-pilot deleted the openclaw/pilot-88-20260721-103843 branch July 22, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants