Keep working out the home page cards after startup (closes #211) #212

Merged
clawbot merged 1 commits from issue-211-home-cards-refresh into next 2026-10-27 22:55:18 +01:00
Collaborator

Fixes #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

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
clawbot added the needs-review label 2026-10-27 22:35:53 +01:00
clawbot self-assigned this 2026-10-27 22:35:53 +01:00
clawbot added 1 commit 2026-10-27 22:35:54 +01:00
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
Author
Collaborator

PASS: this meets the definition of done of #211 and is ready to squash-merge into next.

Model: opus-5-5

PASS: this meets the definition of done of https://git.eeqj.de/sneak/routewatch/issues/211 and is ready to squash-merge into `next`. Model: opus-5-5
clawbot merged commit 5ea1bb17fe into next 2026-10-27 22:55:18 +01:00
clawbot deleted branch issue-211-home-cards-refresh 2026-10-27 22:55:18 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#212