Conversation
acinader
force-pushed
the
web-idle-timeout
branch
from
September 29, 2026 19:59
f9c81a6 to
5f6c104
Compare
…nd tab In the default --serve-browse mode, hledger-web exits once no page has pinged it for a while. Each page sets a timer to ping every 30 seconds, but browsers run the timers of pages in background tabs much less often. Measured on macOS, a hidden Safari tab ran its timer only every 2 to 5 minutes (in one run, every 8 to 11), and a hidden Chrome tab ran it once a minute. So with the 2 minute timeout, hledger-web regularly exited while its page sat open in a Safari tab, and the user came back to a page whose links and forms no longer worked. - The server now exits after 15 minutes without a ping, not 2. - The page also pings as soon as it is shown again, so returning to a tab keeps the server running without waiting for the next timed ping. - When a ping can't reach the server, the page shows a notice saying hledger-web is no longer running and how to continue, instead of failing silently on the next click. A later ping that gets through (eg after a restart on the same address) hides it again. AI usage: Claude Opus 5.5, ~64k output tokens.
acinader
force-pushed
the
web-idle-timeout
branch
from
September 30, 2026 05:01
5f6c104 to
15005c5
Compare
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.
In the default browse mode, hledger-web exits once no page has pinged it for 2 minutes. Pages ask to ping every 30 seconds, but browsers run the timers of background tabs much less often, so hledger-web regularly exited while its page sat open in a background Safari tab. Coming back, the page looked fine but its links and forms no longer worked.
I measured it on macOS with a small probe page that reported each timer tick, left hidden for about 11 hours:
This PR:
The startup and exit messages,
--help, and the manual say 15m. The notice is in the page template, browse mode only.One case this doesn't cover: after a few hours, Chrome may discard a background tab (it did in my overnight run,
document.wasDiscardedwas true). Going back reloads the page from the server, which by then has exited. Only a much longer timeout would help with that; 15 minutes seemed a reasonable default, and--serveremains for leaving it running.The notice uses bootstrap's
.alert-warning, which the dark mode in #2752 doesn't restyle yet. Whichever of the two lands second, I'll rebase it and give the notice its dark colors.Tests: a browser spec case that blocks
/_ping, checks the notice appears, then unblocks and shows the page again and checks it goes away. It fails if either the notice or the ping on showing is removed. All 34 browser tests and the yesod suite pass.How to test
The terminal says "This server will exit after 15m with no browser windows open". Press ctrl-c, then switch away from the hledger-web tab and back: the yellow notice appears. Start it again with the same command and switch back to the first tab: the notice goes away. Leave the page in a background Safari tab for 20 minutes: the server keeps running.
AI usage: Claude Opus 5.5: ~90k output tokens