fix: run all server goroutines under one errgroup#303
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the API, indexer, and relayer servers to run all long-lived background workers and HTTP servers under a single shared errgroup.Group. This ensures coordinated shutdown and prevents race conditions with deferred resource cleanups. Accordingly, background tasks (such as workers, miners, and caches) now return an error instead of running as detached goroutines. The reviewer identified a critical issue in pkg/app/api/server.go where a failure in initServices could cause a goroutine leak because the function returns immediately without waiting for already-spawned background tasks to drain. A fix was suggested to cancel the context and wait for the group to finish on error.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (27.58%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #303 +/- ##
=======================================
Coverage ? 30.64%
=======================================
Files ? 150
Lines ? 11275
Branches ? 0
=======================================
Hits ? 3455
Misses ? 7547
Partials ? 273
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
What
Unifies goroutine lifecycle management across the api, indexer, and relayer servers under a single
errgroupeach, and standardizes the background-worker signatures that feed it.