Sweep at boot, and stop rendering swept captures - #46
Merged
Conversation
The 4 hour retention window is stated on the landing page and on every endpoint page. Two things let reality drift from it. Cron's first tick is a full interval away, so a process restarted more often than every 5 minutes never swept at all and captures outlived the window for as long as the database file did. The sweep now also runs once at startup. An open endpoint page never expired anything from its own list, so a page left open past the window kept rendering captures the server had already deleted, directly under the line promising they were gone. The page now drops them on the interval it already runs for relative timestamps, then refetches so the total and the windowed list come from the server again. The window reaches the page as data-retention-seconds, rendered from the same constant the sweep uses, rather than as a fourth hardcoded copy of the figure. Claude-Session: https://claude.ai/code/session_01XkbFE6pgcxRfsMAvnwyuqS
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Captured requests are deleted after 4 hours. That window is stated on the landing page, on every endpoint page, and in the endpoint page description. Two things let reality drift from it.
The sweep never ran at boot
startRetentionSweepregistered*/5 * * * *with cron and nothing else. Cron's first tick is a full interval away, so a process restarted more often than every 5 minutes never swept at all. Deploys, crash loops, or a platform that recycles the container left captures alive past the window for as long as the database file survived.The sweep body is now a named
sweepRetention, called once before the scheduler starts.Also corrected the doc comment on
startRetentionSweep, which claimed to return "the stopped-on-exit scheduler so the caller owns its lifetime" whilemain()discards the return value and no shutdown path callsStop().An open page kept rendering captures the server had deleted
The client only mutated its list on fetch, socket append, or explicit delete, never on age. The endpoint page is built to sit open for hours, so a row reading "6 hours ago" ended up on screen directly under the line promising deletion after 4 hours.
The store gains
pruneExpired, driven from theTICK_MSinterval the component already runs for relative timestamps, so no second timer. Dropping rows locally is only the immediate half: the list is windowed, so it then calls the existingfetchRequests()to resynctotaland promote any older-but-live capture into the window.The window reaches the page as
data-retention-seconds, rendered byrenderEndpointfrom the same constant the sweep uses, so there is no fourth hardcoded copy of "4 hours". A page served without the attribute skips pruning rather than expiring against a guess.Verification
go vet ./src/...,go test ./src/...,npm run lint,prettier --check, and thenpm run cssstaleness check all pass locally.TestSweepRetentioncovers both directions; newTestPageRoutescase assertsdata-retention-seconds="14400".deleted old requests count=103logged at startup, before the listener came up.totalresynced, no console errors. A fresh capture then survived two further ticks.The e2e suite is not extended here. A Playwright test using
page.clock.fastForwardwould guard the client prune, and can follow.🤖 Generated with Claude Code
https://claude.ai/code/session_01XkbFE6pgcxRfsMAvnwyuqS