fix: stop the access log watcher when Charon shuts down

Open
#2,138 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@Wikid82 is already working on this.

Since Dec 3, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Read backend/internal/services/log_watcher.go and the watcher setup in backend/internal/api/routes/routes.go; compare how the stats ingester and hub receive the application context. Start by tracing LogWatcher.Start(ctx) and its tail loop. Add a test that cancellation stops the loop, then verify the watcher shuts down with server.Run(ctx) and releases its resources.

Written by the indexing model from the issue text.

Description

backend low

What

The access log watcher keeps running until the process exits instead of stopping with the application context.

  • backend/internal/api/routes/routes.go (log watcher block, logWatcher.Start(context.Background())) starts it with a background context, and nothing calls LogWatcher.Stop() at shutdown.
  • LogWatcher.Start(ctx) (backend/internal/services/log_watcher.go:45) ignores its ctx argument; the tail loop watches the watcher's own context created in NewLogWatcher (:34-42).

CLAUDE.md asks long-running work to respect server.Run(ctx).

Severity

Low. The process exits at shutdown anyway; the gap is an unclean stop (open file handle, subscriber channels left open) and a pattern that differs from the stats ingester and hub, which take ctx.

Suggested approach

Have Start derive the tail loop's context from its ctx argument (or call Stop from context.AfterFunc(ctx, ...)), pass the application context from RegisterWithDeps, and add a test that the tail loop ends when the context is cancelled.

Found while planning #2132.

Dominant language
Go
Stars
17
Forks
2
Avg merge
1h 42m
Merged PRs (30d)
173

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Wikid82/Charon

All issues in Wikid82/Charon

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.