Skip to content

fix(start-wrt): hand an outlasted update wait to the reconnect indicator - #4940

Open
Dominion5254 wants to merge 14 commits into
masterfrom
wrt/update-reconnect-timeout
Open

Dominion5254 wants to merge 14 commits into
masterfrom
wrt/update-reconnect-timeout

Conversation

@Dominion5254

@Dominion5254 Dominion5254 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

After an update reboot, the update screen polls the router for several minutes (60 attempts, each a 5 s pause plus a probe of up to 5 s). When that ran out, it closed its progress dialog without a word, leaving a page that still showed the old version.

The path is reached when:

  • the router takes longer than the wait to come back;
  • the tab cannot reach the router for that long;
  • the running firmware no longer admits this tab's encrypted session, which 1.5.0's session transport makes possible, for example after a future session-protocol change.

Found on the 1.5.0 release bench: the tab sat on "Device is restarting…" for about 5.8 minutes and then closed silently.

What changes

  • The wait hands over to the reconnect indicator. When the wait runs out, SystemService.pollForReconnect closes the dialog and reports the outage to ConnectionService. That service owns the "Reconnecting" indicator, which background pollers report into once the update releases its suppression.
    • The indicator says the router has not come back since the update.
    • It reloads the page once the page's own origin answers any HTTP request, which loads the interface the running firmware serves.
    • It probes the origin with the existing no-cors probeUrl check rather than system.info, because the session this tab speaks may be what the running firmware no longer accepts.
    • The reload makes no claim about the update's outcome, because a router that answers may still be downloading.
  • The indicator keeps the explanation (helix's proposal). reportUnreachable() used to set its message before its already-unreachable guard. The next report without options, such as a FormService poll on Devices, therefore replaced the explanation with "Trying to reach the router". It now sets the default message only when an outage starts, and a later report changes the message only when it carries one. Recovery resets everything for the next outage.
    • The same overwrite hit the address-change flows. The LAN IPv4 and Admin-profile pages keep polling while reconnectAt waits, so "Reconnecting to the new address…" became the generic text within a poll or two. It now stays until the page navigates.
    • This has its own fragment and is covered by a test, not the bench: changing the bench's LAN address would renumber the StartOS server on it.
  • "Update now" is unavailable while the router is unreachable. RPC can answer a moment before the indicator's next probe reloads the page. An update started in that gap would be cut off from its progress by the reload. The button is disabled while ConnectionService.unreachable(), and SystemService.startUpdate refuses then as well. The progress dialog closes when the update cannot start, instead of spinning.
  • SystemService reaches sessionStorage and the window through WA_SESSION_STORAGE and WA_WINDOW. The "Updated to v…" confirmation that rides startwrt.updated-to across the in-wait reload works as on master.
  • New string (key 656) in all five dictionaries.
  • Comments. The edited comments in ConnectionService are trimmed and no longer assume every probe targets a new address. The progress dialog's doc says what it does. Comments in both services that assumed an update clears the session are removed.

One limit remains: the indicator promises a reload that never happens if the origin never answers again, for example a Remote Access WAN address that changed during the update.

Verification on ae4b2a8

Merged master 316493c (docs only) after verification, without conflicts.

  • npm run check:rpc-clients: PASS, 108 tests. The regression tests fail on the commit before their fix:
    • On 2dab760, three tests FAIL at the message assertion, where the message becomes "Trying to reach the router":
      • "WRT update recovery that outlasts its wait keeps its explanation through background poller reports", which runs the real ConnectionService through the handover and then an option-less report;
      • "WRT address change keeps its reconnect copy through background poller reports";
      • "WRT outage ownership retains explicit recovery copy and aborts once per outage".
    • On d503bce, the commit before the guard, two tests FAIL:
      • "WRT update refuses to start while the reconnect indicator is up": "Missing expected rejection", because the update started.
      • "WRT update progress dialog closes when the update cannot start": completeWith was never called.
    • Coverage test: "WRT update into a new interface carries its confirmation across the reload".
  • npm run check:wrt and npm run build:wrt: PASS.
  • Prettier and node scripts/changelog.mjs check-version projects/start-wrt: PASS.
  • K1 bench, with this branch and fix: answer a clock-skewed session hello with the server's time #4939 merged locally and deployed. A stand-in registry offered "1.5.1" with a download that never answers, so nothing flashed. Dropping the UI tunnel made the router unreachable from the tab.
    • Before (2dab760): the update started from Settings → General, and the indicator appeared with the update explanation at +318 s. Four seconds after switching to Devices in-app, it read "Trying to reach the router".
    • After (7f6086e, the same rule as dfa47e2's canStartUpdate()):
      • "Update now" was enabled before the update and disabled once the indicator appeared at +317 s.
      • The explanation stayed on Devices for the 74 s until the router came back.
      • The page reloaded 4 s later and showed no outcome toast.
    • bench.sh smoke PASS.
    • ae4b2a8 differs from the benched build in the refusal copy, the shared canStartUpdate(), the tests and comments. Those changes are covered by tests and type-checked, but not benched.

After an update reboot the UI probes the router for five minutes, then
cleared its progress dialog without a word, leaving a page that still
showed the old version. 1.5.0 makes that path reachable whenever the
encrypted session cannot be re-admitted: a downgrade to firmware without
/rpc/v2, or a future session-protocol change.

The timeout now hands the wait to ConnectionService, the owner of the
"Reconnecting" indicator that background pollers already report into
once the update releases its suppression. It says the router has not
come back since the update and reloads the page once the router answers
any HTTP request, which loads the UI the running firmware serves. It
probes the origin rather than polling system.info because the session
this page speaks may be what that firmware no longer accepts.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the update-timeout explanation through subsequent poller failures. The handover in system.service.ts supplies the new message, but ConnectionService.reportUnreachable() unconditionally replaces it before its already-unreachable guard. After the dialog closes, navigating to a polling page such as Devices causes FormService to report its next network failure without options, replacing the update explanation and reload promise with “Trying to reach the router.” The reload intent survives; its explanation does not. The added test stubs the connection owner, so it misses this transition.

The proposal initializes default copy on entry and preserves the active message on unlabelled reports. Explicit messages can still refine it, and recovery resets the context for the next outage. It records that contract at the owner and extends its lifecycle regression coverage through recovery and a fresh outage.

Comment cleanup: trims adjacent redundant prose and removes the assumption that every HTTP probe targets a different origin.

The reviewed head merges cleanly with origin/master. I did not build or run tests; the proposed test is unexecuted for the author to verify upon adoption.

Proposed changes: 2dab760...proposal/4940

To adopt the proposal, cherry-pick it onto your branch rather than merging or pulling it, so the PR's head stays your own commit:

git fetch https://github.com/Start9Labs/start-technologies.git proposal/4940
git cherry-pick 2dab760287e3ba3781ecd1d410b7306dea1e8da9..FETCH_HEAD

If your branch has moved since 2dab760287e3ba3781ecd1d410b7306dea1e8da9, resolve any conflicts the cherry-pick reports, or apply the changes your own way. Then push and say so in a comment.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

helix-white and others added 10 commits November 25, 2026 08:43
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
…ervice

The handover test stubbed the reconnect owner, so it could not see a later
background report replace the explanation. It now constructs the real
ConnectionService, lets the update wait expire into it, reports the outage
again without options the way a FormService poller does, and checks that the
explanation stays until the origin probe answers and the page reloads.

A second case covers the address-change flow, whose page keeps polling after
reconnectAt hands over.
… copy

Keeping the active outage's message on unlabelled reports also stops the
LAN IPv4 and Admin-profile pages' own pollers from replacing "Reconnecting
to the new address…" with the generic copy while reconnectAt waits.
When the update wait ran out, the reconnect indicator reloaded the page
once the router answered, but nothing told the reloaded page which version
was requested. A slow update that succeeded reloaded with no "Updated to"
confirmation, and one that came back on the old version reloaded with no
failure message.

The handover and the in-wait reload into a new interface now both store
the requested version, and init() compares it with the version the router
reports: a match shows "Updated to v…", anything else shows "Update
failed — check device logs". init() checks it from system.info alone, so an
unreachable registry cannot drop the outcome. It still honours the
confirmed version an earlier release's update page stores before reloading.

The fragment now says what the user sees: the update screen closes, a
Reconnecting notice explains the wait, and the wait is several minutes
rather than five (each of the 60 attempts is a 5 s pause plus a probe of
up to 5 s).

Tests drive the real ConnectionService through a handover into an outage
already in progress, count the system.info calls the origin probe
replaces, and check init()'s outcome for a match, a mismatch, an earlier
release's key, no key, and an unreadable firmware.
The update handover probes the page's own origin and reloads, so the
comments that assumed every probe targets a new address, that recovery
always toasts "Connection restored", and that a declared disruption
carries recovery intent no longer held. The progress dialog's doc now says
what it does rather than listing SystemService's paths.
… version

Pre-review findings on the outcome report:

- The requested version was removed from sessionStorage before the reloaded
  page read system.info, so a failed first read lost the verdict for good.
  setInfo() now settles it, from init() as soon as system.info answers
  (without waiting for system.newer-versions, which can fail or stall) or
  from the 30 s refresh, and the key stays until a version is read.
- SystemService takes sessionStorage and the window through WA_SESSION_STORAGE
  and WA_WINDOW, as the app's other window users do.
- The handover reports the outage before writing storage, so a storage
  failure cannot cost the indicator.
- The fragment says what is compared: whether the router runs the new
  version.
- Comments that assumed sysupgrade clears sessions, that an update without a
  lost connection failed before rebooting, and that mock recovery only skips
  navigation are cut to what holds.

Tests: the outcome keeps its key through an unreadable system.info until
refresh() reads a version, arrives while system.newer-versions is still
pending, and the update tests pass storage and window as fields and count
toasts instead of throwing inside pollForReconnect's catch-all.
The reloaded page compared the version it was asked to install with the
one the router reported and showed "Update failed — check device logs" on
a mismatch. A router that answers while still downloading reports the old
version, so the page could call a running update failed where the base
said nothing. No verdict is correct until the router reports an update in
progress, so the report goes:

- startwrt.update-target, its write before the handover and the in-wait
  reload, and its settlement in setInfo()/init() are removed.
- The in-wait reload into a new interface again stores the requested
  version under startwrt.updated-to and init() shows it, as on master.
- The fragment no longer claims a verdict after the reload.

SystemService keeps reaching sessionStorage and the window through
WA_SESSION_STORAGE and WA_WINDOW for the uses that remain. Comments that
assumed an update clears sessions or that a dropped stream without an
outage means a failed update are cut to what holds.

Tests: the outcome cases go; one test now drives the in-wait reload and
the reloaded init() through the legacy key.
system.info needs no session, but an update keeps the session store, so
the comment's claim that the check works "even when the update wiped the
session" described a case that does not occur.
…eachable

Once the update wait hands over, the reconnect indicator reloads the page
on the first probe the origin answers. RPC can answer a moment before
that probe, so "Update now" could start a second update that the reload
then cut off from its progress.

The button is disabled while ConnectionService reports the router
unreachable, and SystemService.startUpdate refuses then as well, before it
suppresses the indicator or sends system.update. The progress dialog
closes when the update cannot start instead of spinning on an update that
never began.

The update fragment gains a line for the button.
Pre-review follow-ups on the "Update now" guard:

- SystemService.canStartUpdate() holds the rule (not updating, router
  reachable); the button and startUpdate's refusal both use it.
- A refused start toasts "Failed to start update" rather than repeating the
  indicator's "Trying to reach the router".
- A test drives the progress dialog's start failure and checks that the
  dialog closes and toasts once.
- Comments: system.info needs no sign-in (every RPC still needs the
  session), the toast's tailored-copy example names a caller that uses it,
  and two comments that restated the code are removed.
The refusal test asserted canStartUpdate() first, so before the guard it
failed on the missing method rather than on an update that started. It
now checks the refusal first. reachable()'s doc says "when" for a
per-call result.
The dialog closes once its update has finished, not whenever SystemService
is idle. The toast doc no longer argues for itself or gives an example
the copy never shows. The coverage test for a handover into an outage
already in progress goes: the "Update now" guard makes that state
unreachable.
@Dominion5254

Copy link
Copy Markdown
Member Author
  • P2, the update explanation replaced by the next poller report: adopted as proposed (cherry-picked as 6710137). The handover test now drives the real ConnectionService through the handover and an option-less report, and fails on 2dab760. The bench confirms the explanation holds on Devices until the reload.
  • Also in this push:
    • "Update now" is unavailable, and startUpdate refuses, while the router is unreachable, so an update cannot start in the moment before the indicator reloads the page.
    • The address-change copy is covered by the same message fix.
    • Comments and the fragment now match the code.

Pushed 2dab760..37e6817 (ae4b2a8 plus a docs-only master merge).

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 37e6817, which is ae4b2a8 plus a master merge that adds only master's docs change. My earlier request is resolved: the proposal is adopted unchanged, and the handover tests now drive the real ConnectionService. The rest of the push is correct:

  • the "Update now" guard and its single canStartUpdate() rule;
  • the dialog closing when a start fails;
  • the WA_SESSION_STORAGE / WA_WINDOW injection;
  • the five dictionary entries;
  • both changelog fragments. StartWRT v1.4.0 shipped both the silent timeout and the overwritten address message, so each fragment describes a fix to released behavior.

The head merges cleanly with master.

Brief

Summary

  • Outlasted update wait. After an update, the progress dialog waits 60 attempts. Each is a 5 s pause plus a system.info probe of up to 5 s, so the wait lasts 5 to 10 minutes. When it ran out, the dialog used to close silently on the old page.
    • It now closes into the existing "Reconnecting" notice, which reads "The router has not come back since the update. This page reloads when it does."
    • The notice fetches /static/local-root-ca.crt from the page's own origin every 3 s. The fetch is no-cors, so any HTTP answer counts.
    • On the first answer it reloads the page, which loads the UI the running firmware serves. The reload says nothing about whether the update succeeded.
  • The notice keeps the message its outage started with, a change proposed in @helix-white's earlier review.
    • Before, reportUnreachable() set its message ahead of its already-unreachable check. The next report without a message replaced the copy with "Trying to reach the router"; a form page's 5 s poll is one such report.
    • It now sets the default only when an outage starts, and a later report changes the message only when it carries one. Recovery clears the outage's state.
    • The same fix keeps "Reconnecting to the new address…" through the LAN IPv4 and Admin-profile address changes. Those pages keep polling while the browser waits to move to the new address.
  • "Update now" is disabled while the notice is up, for any outage, and SystemService.startUpdate refuses to start then. When an update cannot start, whether refused or rejected by the router, the progress dialog closes and shows the error as a toast ("Failed to start update" for a refusal). Before, a refused start would have left the dialog spinning.
  • Additional changes:
    • SystemService reaches sessionStorage and the window through the WA_SESSION_STORAGE / WA_WINDOW injection tokens. The "Updated to v…" confirmation across the in-wait reload behaves as on master.
    • Comments in both services are cut to their contracts: 103 comment lines removed, 20 added.

Implementation diff: +35 / −10 lines in 9 files (excludes lockfiles, tests, docs, release notes, and changelog). The count treats every comment line, // and doc comments alike, as documentation, and the five dictionary entries as implementation.

Approach

  • The handover reuses ConnectionService's outage handling and its probeUrl origin probe, which the address-change flows already use, rather than extending SystemService's own wait loop.
  • It probes the origin rather than system.info because every RPC, system.info included, needs this tab's encrypted session. Firmware with a different session protocol may not accept that session, while the origin probe only needs an HTTP answer.
  • canStartUpdate() (not updating and not unreachable) is the single rule behind both the button and the refusal. It ignores the reboot wait, when the blocking progress dialog already covers the button.

Tradeoffs

  • After the reload, the user sees the version the router reports but no "Updated to" or "Update failed" message. The author tried a verdict and removed it: a router that answers while still downloading reports the old version, so a working update would have been called failed. A correct verdict needs the router to report an update in progress.
  • The origin may never answer again, for example when the update changed a Remote Access WAN address. Then the notice and the disabled button stay until the user reloads or navigates away. Unlike reconnectAt, this handover has no fallback that forces navigation after a time limit.

Screenshots are in the comment that follows this review, captured from this head.

Testing

  • The author's run on ae4b2a8 (the head without the docs-only merge):
    • npm run check:rpc-clients passes, 108 tests. The new tests fail on the commits before their fixes: the three message tests on 2dab760, and the refusal and dialog-close tests on d503bce.
    • check:wrt, build:wrt, Prettier and changelog.mjs check-version pass.
  • The author's K1 bench run. The build also carried open #4939, which changes the shared session transport and touches none of these files. A stand-in registry offered an update whose download never answers, and the UI tunnel was dropped.
    • Before the fix, the notice appeared at +318 s and turned generic 4 s after switching to Devices.
    • After it, "Update now" was disabled from +317 s, and the explanation stayed on Devices for the 74 s until the router came back. The page reloaded 4 s later with no outcome toast, and bench.sh smoke passed.
    • The refusal copy, the shared canStartUpdate(), the tests and the comments changed after the bench run.
  • My screenshot capture, not a test run. I used a development build of this head's StartWRT UI with the mock backend in headless Chromium, with timers fast-forwarded. Every RPC after system.update failed as a network error and the origin probes were refused. I then clicked "Update now".
    • The handover came after the 60th failed attempt. The dialog closed, the notice showed the explanation, and "Update now" was disabled.
    • On Devices, the explanation stayed through 20 s of failed background polls.
    • Once the probes could answer, the page reloaded.
    • This ran the production code paths against a mock backend, not a firmware update.
  • CI on 37e6817:
    • Prettier, Formatting & Lockfiles, Changelog fragments & versions, Dependency Licenses and Conflict Markers pass.
    • Still pending: "Build riscv64 binary" (make start-wrt, which compiles this UI), "StartWRT Tests" and the other build and test jobs.
    • No CI job runs npm run check:rpc-clients, which holds these regression tests, or check:i18n:wrt. The author's run above is their only record.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

@helix-white

Copy link
Copy Markdown
Member

Screenshots for the approval brief above (this head, 37e6817).

Settings → General after the update wait runs out: the Reconnecting notice explains the wait and promises a reload, and "Update now" is disabled

Devices after 20 s of failed background polls: the notice keeps the update explanation instead of switching to "Trying to reach the router"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants