Skip to content

fix(daemon): register echo service listener with bgWG (PILOT-88)#406

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-88-20260720-113134
Open

fix(daemon): register echo service listener with bgWG (PILOT-88)#406
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-88-20260720-113134

Conversation

@matthew-pilot

Copy link
Copy Markdown
Collaborator

What

The startEchoService goroutine was the last daemon-scoped goroutine not registered with d.bgWG. During graceful shutdown, the echo listener exited correctly (select on d.stopCh) but was unaccounted for in the WaitGroup — meaning bgWG.Wait() could return before the listener had fully stopped if it was racing with port teardown.

Why

This is a continuation of the mechanical sweep described in PILOT-88: the core loops (routeLoop, trustRepublishLoop, etc.) already used bgWG, but the echo service was missed. Adding d.bgWG.Add(1) / defer d.bgWG.Done() ensures the shutdown sequence waits for the echo listener to exit before tearing down port infrastructure.

Verification

  • go build ./pkg/daemon/ — clean
  • go vet ./pkg/daemon/ — clean
  • go test -count=1 ./pkg/daemon/ — all tests pass (36.6s)
  • 8 echo-service-specific tests all pass (TestStartEchoService*, TestStartBuiltinServices*)

Closes PILOT-88

The startEchoService goroutine was the last daemon-scoped goroutine
not registered with d.bgWG. During graceful shutdown, the echo
listener exited correctly (select on d.stopCh) but was unaccounted
for in the WaitGroup — meaning bgWG.Wait() could return before the
listener had fully stopped if it was racing with port teardown.

This is a continuation of the mechanical sweep described in PILOT-88:
the core loops (routeLoop, trustRepublishLoop, etc.) already used
bgWG, but the echo service was missed. Adding d.bgWG.Add(1) /
defer d.bgWG.Done() ensures the shutdown sequence waits for the
echo listener to exit before tearing down port infrastructure.

Closes PILOT-88
@matthew-pilot
matthew-pilot requested a review from TeoSlayer as a code owner July 20, 2026 11:32
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.

1 participant