What changed.Server.Start now runs the loop that works out the home page's cards on a context that only Server.Stop ends. It uses context.WithoutCancel plus a cancel, as blocklist does. The loop used to run on the context fx passes to OnStart. fx ends that context once start-up is done, so the cards were worked out once and never again.
Stop ends the loop and waits for it to return, until its own context ends, before it shuts the HTTP server down. RouteWatch.Shutdown closes the database right after Stop, so no refresh is left reading it.
What the diff does not show.
Stop checks that the loop was started. Start returns before it starts the loop when it cannot listen, and RouteWatch.Shutdown still calls Stop then. TestStopClosesTheConnectionOfARequestStillRunning also builds a Server by hand without starting it.
The new test runs Start in a testing/synctest bubble and moves the bubble's fake clock with time.Sleep, which returns at once there. No real time passes.
The test closes the HTTP server itself first: a goroutine waiting on the network keeps the bubble's clock still.
It builds the server outside the bubble, because the streamer's metrics start a goroutine that never returns.
Judgement call: Stop waits for the loop before it shuts HTTP down, not after. A deadline that ends during that wait still closes every connection.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/routewatch/issues/211.
**What changed.** `Server.Start` now runs the loop that works out the home page's cards on a context that only `Server.Stop` ends. It uses `context.WithoutCancel` plus a cancel, as `blocklist` does. The loop used to run on the context fx passes to `OnStart`. fx ends that context once start-up is done, so the cards were worked out once and never again.
`Stop` ends the loop and waits for it to return, until its own context ends, before it shuts the HTTP server down. `RouteWatch.Shutdown` closes the database right after `Stop`, so no refresh is left reading it.
**What the diff does not show.**
- `Stop` checks that the loop was started. `Start` returns before it starts the loop when it cannot listen, and `RouteWatch.Shutdown` still calls `Stop` then. `TestStopClosesTheConnectionOfARequestStillRunning` also builds a `Server` by hand without starting it.
- The new test runs `Start` in a `testing/synctest` bubble and moves the bubble's fake clock with `time.Sleep`, which returns at once there. No real time passes.
- The test closes the HTTP server itself first: a goroutine waiting on the network keeps the bubble's clock still.
- It builds the server outside the bubble, because the streamer's metrics start a goroutine that never returns.
Judgement call: `Stop` waits for the loop before it shuts HTTP down, not after. A deadline that ends during that wait still closes every connection.
Model: opus-5-5
Server.Start ran the loop that works out the home page's cards on the
context it was given. fx ends that context once start-up is done, so the
cards were worked out once and never again. The loop now runs on a
context that only Stop ends, as the other background parts do. Stop
waits for the loop to return, until its own context ends, before it
stops the HTTP server.
A new test starts a server in a synctest bubble and ends its context at
once. On the bubble's fake clock, the cards must be worked out again a
minute later, and not after Stop.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #211.
What changed.
Server.Startnow runs the loop that works out the home page's cards on a context that onlyServer.Stopends. It usescontext.WithoutCancelplus a cancel, asblocklistdoes. The loop used to run on the context fx passes toOnStart. fx ends that context once start-up is done, so the cards were worked out once and never again.Stopends the loop and waits for it to return, until its own context ends, before it shuts the HTTP server down.RouteWatch.Shutdowncloses the database right afterStop, so no refresh is left reading it.What the diff does not show.
Stopchecks that the loop was started.Startreturns before it starts the loop when it cannot listen, andRouteWatch.Shutdownstill callsStopthen.TestStopClosesTheConnectionOfARequestStillRunningalso builds aServerby hand without starting it.Startin atesting/synctestbubble and moves the bubble's fake clock withtime.Sleep, which returns at once there. No real time passes.Judgement call:
Stopwaits for the loop before it shuts HTTP down, not after. A deadline that ends during that wait still closes every connection.Model: opus-5-5
PASS: this meets the definition of done of #211 and is ready to squash-merge into
next.Model: opus-5-5