Skip to content

fix: run all server goroutines under one errgroup#303

Merged
dhyaniarun1993 merged 2 commits into
mainfrom
refactor/server-errgroup-lifecycle
Jun 8, 2026
Merged

fix: run all server goroutines under one errgroup#303
dhyaniarun1993 merged 2 commits into
mainfrom
refactor/server-errgroup-lifecycle

Conversation

@dhyaniarun1993

Copy link
Copy Markdown
Member

What

Unifies goroutine lifecycle management across the api, indexer, and relayer servers under a single errgroup each, and standardizes the background-worker signatures that feed it.

@dhyaniarun1993 dhyaniarun1993 self-assigned this Jun 8, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pkg/app/api/server.go
@codecov-commenter

codecov-commenter commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.58621% with 21 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@9a5ccbd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/app/api/server.go 0.00% 12 Missing ⚠️
pkg/app/indexer/server.go 0.00% 4 Missing ⚠️
pkg/app/relayer/server.go 0.00% 3 Missing ⚠️
pkg/user/service/topology_cache.go 0.00% 2 Missing ⚠️

❌ 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

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #303   +/-   ##
=======================================
  Coverage        ?   30.64%           
=======================================
  Files           ?      150           
  Lines           ?    11275           
  Branches        ?        0           
=======================================
  Hits            ?     3455           
  Misses          ?     7547           
  Partials        ?      273           
Flag Coverage Δ
unittests 30.64% <27.58%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/custodial/accept_worker.go 95.00% <100.00%> (ø)
pkg/ethrpc/miner/miner.go 97.84% <100.00%> (ø)
pkg/ethrpc/submitter/submitter.go 77.70% <100.00%> (ø)
pkg/transfer/cache.go 94.87% <100.00%> (ø)
pkg/user/service/topology_cache.go 0.00% <0.00%> (ø)
pkg/app/relayer/server.go 0.00% <0.00%> (ø)
pkg/app/indexer/server.go 0.00% <0.00%> (ø)
pkg/app/api/server.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dhyaniarun1993 dhyaniarun1993 merged commit 16ffa3e into main Jun 8, 2026
3 checks passed
@dhyaniarun1993 dhyaniarun1993 deleted the refactor/server-errgroup-lifecycle branch June 8, 2026 13:05
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.

3 participants