Skip to content

fix: shut down gateway and metrics server concurrently - #17

Merged
Brunotlps merged 1 commit into
mainfrom
fix/issue-7-shutdown-ctx
Jun 16, 2026
Merged

fix: shut down gateway and metrics server concurrently#17
Brunotlps merged 1 commit into
mainfrom
fix/issue-7-shutdown-ctx

Conversation

@Brunotlps

Copy link
Copy Markdown
Owner

Summary

  • A single 30s context.WithTimeout was shared between two sequential Shutdown calls
  • context.WithTimeout starts its timer at creation time — if srv.Shutdown consumed 29s of the budget, metricsSrv.Shutdown received a nearly-expired context
  • This caused active connections (e.g. in-flight Prometheus scrapes) to be aborted instead of drained, with the process exiting 0 as if nothing was wrong
  • Both servers now shut down concurrently via goroutines coordinated by sync.WaitGroup, each receiving the full 30s budget

Test plan

  • go build ./... succeeds
  • go test -race ./... passes with no failures

Closes #7

🤖 Generated with Claude Code

A single 30s context was shared between two sequential Shutdown calls.
If srv.Shutdown consumed most of the budget, metricsSrv.Shutdown received
an already-expired context and aborted active connections (e.g. Prometheus
scrapes) without draining.

Both servers now shut down concurrently via goroutines coordinated by a
sync.WaitGroup, giving each the full 30s budget independently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Brunotlps
Brunotlps merged commit ca06747 into main Jun 16, 2026
1 check passed
@Brunotlps
Brunotlps deleted the fix/issue-7-shutdown-ctx branch June 16, 2026 18: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.

fix: normalize path uses HasPrefix without segment boundary, causing prefix collision

1 participant