fix: retry the post-update dashboard auto-open instead of trying once - #5616
Merged
Conversation
update.sh/update.ps1 already open the dashboard in the PortOS-managed browser after a restart, but a full `pm2 delete` + `pm2 start` of the ecosystem makes Chrome a cold launch racing the busiest moment of the update (npm install, client build). The auto-open script fired one navigate attempt and gave up silently on failure, so Chrome would come up with no tab pointed anywhere whenever it lost that race. Fold the browser-health poll and single navigate attempt into one retry loop that keeps POSTing /api/browser/navigate for up to 60s, long enough to outlast a cold Chrome launch under load.
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.
Summary
update.sh/update.ps1already open the PortOS dashboard in the managed Chrome browser after an update finishes, but the auto-open script fired a single navigate attempt and gave up silently on failure. A full self-update doespm2 delete+pm2 startof the whole ecosystem (includingportos-browser), so Chrome cold-launches right as CPU/disk are busiest fromnpm install/the client build — that race was regularly lost, leaving Chrome open with no tab pointed at the dashboard.Changes
scripts/open-ui-in-browser.js: replaced the browser-health poll + single navigate attempt with one retry loop (navigateWithRetry) that keeps POSTing/api/browser/navigatefor up to 60s, long enough to outlast a cold Chrome launch under load. Refactored into a testablemain()guarded byisDirectlyInvoked, matching the pattern used by otherscripts/*.jsCLI gates (e.g.pm2-daemon-refresh.js).scripts/open-ui-in-browser.test.js: new tests fornavigateWithRetrycovering an immediate success, retrying past transient connection failures, exhausting the retry budget, and treating a non-ok HTTP response (e.g. a blocked-URL 400) as retryable rather than a throw.Test plan
npx vitest run scripts/open-ui-in-browser.test.js— 4/4 passingnpx vitest run(full server suite, which globs../scripts) — 1808 files / 36809 tests passing