667317159's servedAnew reloads a magpie web page once another version
of magpie answers for it. Clicked back into on the Settings page, the
page reads /api/update twice, for the badge and for the Version row,
and each answer called location.reload(). When the second answer comes
a few ms after the first, Chromium starts the reload again and the page
is loaded twice. The whole GUI suite at 667317159 on the Linux box
caught it: update-served-anew's "en at 420" and "zh at 420" counted 3
loads (gui-full.log). servedAnew now reloads once per page.
The test answers the second post-update read 5 ms after the first, as a
busy machine does, and counts the loads after the page has settled.
app.js's comments on it are shorter, so app.js is 264 bytes smaller
than origin/main's; TestCoreScriptBudget is red on main already
(1534819 > 1533802, #5139) and stays red, 264 bytes less over.
Run (Linux box, magpie-desktop, through wsl-run, at e17b6cefc + this):
- node --test internal/gui/tests/update-served-anew.test.cjs three
times: 34/34 each (Chromium and WebKit, 5 languages, 1100 and 420).
- go test -tags nogui -run 'Budget|Script|Asset|I18n|Boot'
./internal/gui/: only TestCoreScriptBudget red, the same at
origin/main e17b6cefc alone (#5139).
Broken by hand: servedAnew calling location.reload() on every answer
again: the 10 Chromium "clicked back into" subtests red (3 loads).
WebKit passes either way; it doesn't start a second reload.
Not tried: the whole GUI suite again with this; mote (busy with other
sessions' suites).
visamzh on X: with the desktop app and magpie web both open, an update
from either side left the other still offering it ("↑ 更新") until it was
quit by hand.
Cause: the app and magpie web are two processes over one program, each
with its own updater (state, download, latest) in memory. One restarting
to update puts the new binary in; the other is told nothing. Its
replaced() (the binary on disk is no longer the one it started from) was
read only on a click of its own Update or on magpie update's gateway ask
(restartBeside), which reaches only the process serving the gateway. And
a browser's page reloaded (backAsNew) only after a restart it asked for
itself, so magpie web's tab kept the old page and its pill even once
the process under it was new.
Fix:
- followReplaced (update_beside.go): every updater stats its binary each
5 s and, once another magpie replaced it, restarts into it through
restartBeside, once: at once when idle, else after the gateway's
requests (waitIdle), as for magpie update's ask. Not for what this
process put in itself (installed, set by install, cleared by
wontStart), not twice (followed), not for a build that isn't a release
(make dev, go build rebuild in place). It stops with backendCtx, so a
copy left draining after a handover doesn't look.
- waitFor (update_wait.go): a wait for the gateway restarts into what
another magpie put in whatever the feed says now; before, a feed out
of reach or a "latest" answer ended the wait with nothing restarted.
- boot.js names the version that served the page (bootPrefs.version);
app.js's servedAnew reloads a browser's page (web) when /api/update's
current names another, on the reads it already made (load, focus, back
into view) and once a minute while shown. The app's own windows come
back with their new process and are left alone.
- docs/subsystems/gui-shell.md describes it.
Run (mote, through mote-run, at 1e1068c86 + this change unless said):
- gofmt -l internal/gui: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
build: all ok.
- go test -tags nogui -race -count=5 -run
'Follow|AnotherMagpies|OwnUpdate|OwnBuild|UpdateClicked|Wait|Beside|
Restart|Install|WhatsNew|Quiet' ./internal/gui/: ok (102.9s).
- go test -tags nogui -timeout 45m ./internal/gui/... ./internal/cli/...
./internal/update/... . : gui, update, update/launcher and magpie ok;
internal/cli red in TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply has no command), red the same on origin/main
51fa4b7eb alone, filed as #5026 (from 0872bc2a0).
- node --test internal/gui/tests/update-served-anew.test.cjs: 34/34
(Chromium and WebKit; en, zh, zh-TW, ja, de; 1100 and 420 wide; the
minute poll under page.clock; the app's window not reloaded).
Broken by hand, each red, then put back:
- followReplaced never restarting: TestAnotherMagpiesUpdateRestartsThisOne
and TestAnotherMagpiesUpdateWaitsForTheGatewayThenRestarts red.
- the installed guard dropped: TestOwnUpdateIsNotFollowedAgain and
TestUpdateClickedOverAnothersIsNotFollowedAgain red (a second restart).
- waitFor's "in" case off: TestAnotherMagpiesUpdateWaitsForTheGateway
ThenRestarts red (the wait ends with nothing restarted).
- boot.js without the version: TestBootNamesTheVersionThatServedThePage
red.
- servedAnew not reloading: 15 of 16 subtests red in Chromium.
- the minute poll removed: the 5 "left on screen" subtests red in WebKit.
A first cut also refused a second install() once one was in; that made
TestRestartBySelfComesBackQuietly and TestWhatsNewQuietAfterRestartTo
Update red (they restart one updater several times), so the flag only
keeps followReplaced off.
Not tried: a real pair of the app and magpie web on two release builds
with one replacing the binary (only temp files and fakes); Windows
(InstallBinaryAside starts the staged file there, so the own-install
test is skipped and the click test covers the flag) and Linux runs;
the whole GUI suite: mote was never free (two other sessions' full GUI suites, load ~400), so it runs on the Linux box after this lands.