You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The local Guard daemon keeps running after the caller cancels context. runDaemon started the runtime service with context.Background() and the HTTP server had no shutdown path tied to the caller context, so tests or supervisors could hang until process exit.
Where We Want To Go
The daemon should stop when the caller context is canceled. kontext start should return cleanly after shutdown instead of leaving the socket and HTTP listener alive.
How do we get there
Thread the caller context into the local runtime service and the HTTP server, treat http.ErrServerClosed as a normal shutdown, and add a regression test that starts the daemon, waits for it to come up, cancels context, and asserts clean return. Verified with go test ./..., go vet ./..., npm exec --yes --package pnpm@10.0.0 -- pnpm install --frozen-lockfile, npm exec --yes --package pnpm@10.0.0 -- pnpm --dir web/guard-dashboard typecheck, and git diff --check.
Run accepts a context.Context, and this path now forwards it directly into localruntime.Service.Start. That method calls context.WithCancel(ctx), which panics when ctx is nil. Before this change, runDaemon used context.Background() for the runtime service and the server path now has its own nil guard, so an embedded caller passing nil can crash before the daemon returns an error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Where We Are
The local Guard daemon keeps running after the caller cancels context.
runDaemonstarted the runtime service withcontext.Background()and the HTTP server had no shutdown path tied to the caller context, so tests or supervisors could hang until process exit.Where We Want To Go
The daemon should stop when the caller context is canceled.
kontext startshould return cleanly after shutdown instead of leaving the socket and HTTP listener alive.How do we get there
Thread the caller context into the local runtime service and the HTTP server, treat
http.ErrServerClosedas a normal shutdown, and add a regression test that starts the daemon, waits for it to come up, cancels context, and asserts clean return. Verified withgo test ./...,go vet ./...,npm exec --yes --package pnpm@10.0.0 -- pnpm install --frozen-lockfile,npm exec --yes --package pnpm@10.0.0 -- pnpm --dir web/guard-dashboard typecheck, andgit diff --check.