Skip to content

fix(shell): 404 for a missing /assets/ file, new shell file names, one reload when the shell fails to load - #4413

Merged
devswha merged 4 commits into
mainfrom
fix/preload-error
Nov 21, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/preload-error

Conversation

@devswha

@devswha devswha commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What broke

Two Android phones got "Something went wrong" / Unable to preload CSS for https://app.ovis.sh/assets/shell-2Jhdistb.css on every start of 0.5.8, though the file answered 200 text/css to curl.

Cause, reproduced: app.ovis.sh (Cloudflare Pages, no 404.html) answers a file its deployment lacks with index.html, status 200, and the /assets/* rule adds Cache-Control: public, max-age=31536000, immutable (plus nosniff):

$ curl -sD - -o /dev/null https://app.ovis.sh/assets/nonexistent-abc123.css
HTTP/2 200
content-type: text/html; charset=utf-8
x-content-type-options: nosniff
cache-control: public, max-age=31536000, immutable

A phone that asked for shell-2Jhdistb.css while the deployment did not serve it yet kept the page as that stylesheet for a year. The browser refuses it (text/html with nosniff), and Vite's preload throws, so bootRelayShell drew AppCrash. The phone never asks again. A Chromium repro on the real v0.5.8 dist-shell (the shell CSS answered once with the page under those headers, then correctly) crashes on opens 1, 2 and 3, and the server sees one request. Not the native shell: desktop Chromium with the Android app's opening probe does not reproduce, and 0.5.7 already lazy-loaded shell-DjCZ9LVt.css the same way.

The fix

  • Hosting (scripts/shell-build.ts): the shell ships assets/404.html. Pages looks for the nearest 404.html above a missing path, so a missing /assets/* file is now a 404. Pages replaces any Cache-Control on a 404 with no-store (workers-sdk pages-shared/asset-server/handler.ts), so the next load asks again. Every other path keeps the single-page fallback. The Caddy site (regional mirror) now pins only files that exist (file matcher); a missing one is no-store. Pages already keeps assets of earlier deployments for a week (its asset preservation cache), so old hashed files stay reachable after a deploy.
  • New names: a shell build of main kept 514 of 604 /assets names identical to 0.5.8, shell-2Jhdistb.css among them, so 0.5.9 would hit the poisoned cache again. The shell's hashed files (code, styles, workers) now take ten hash characters instead of eight, so none reuses an address 0.5.8 served. After this change only theme-bootstrap-f10f765732.js keeps its name: it is a classic script, and if refused the page draws with the default theme.
  • Client (src/lib/relay/boot.ts): when the shell's code fails to load, the page reloads once (guarded in sessionStorage, cleared by a successful load). If it fails again, it shows a small notice with Try again instead of the crash screen. No retry inside the page: Chrome keeps a failed import's answer for the page's life, and Vite's loader skips a stylesheet it already tried.
  • scripts/pages-static.ts (the loopback Pages the browser regressions use) now answers a missing file as Pages does: the 404.html walk, then the single-page fallback, with no-store on any 404. Before, it gave a plain 404 that Pages never sends, which hid this bug.

Design reference: the Codex and Claude apps show a small inline retry state when the app shell fails to load, not a crash report; this follows that.

Before / after

On the Android emulator (Chrome 145, Android 17 image), with the shell stylesheet answered as the page under the immutable header: v0.5.8 shows "Something went wrong" on every open (the server saw one request across two opens). This branch shows "Ovis could not load. Check your connection, then try again." with a Try again button. Screenshots were handed to the lead.

Review fixes (bdffae2)

  • Gate review HIGH: the guarded reload reloaded the address boot had already stripped, so a pairing offer, a sign-in return or a query was lost. reloadEntry now restores the entry address before reloading, and the reloaded page strips it again. Repro: a valid /s/<id>/#offer=... with the first shell CSS missing now reloads once and shows "Pair with ?"; before the fix it showed "Add a PC".
  • Gate review MEDIUM: AppLoadFailed renders before SettingsProvider sets the language, so it now resolves the saved/system language itself (the ko notice is tested).
  • LOW: pages-static walks the decoded path for 404.html, as Pages does.

Review fixes, round 2 (7c04735)

  • Try again now retries at the entry address too, so a pairing offer or sign-in return survives a notice -> Try again.
  • reloadAddress never sends the entry's query to the host again: the query moves into the fragment, as takeEntryUrl keeps it. It returns no address once the tab navigated while the shell loaded, so that navigation stays.
  • Browser repro: two misses -> notice -> Try again -> "Pair with ?"; /?file=... with one miss -> the second document request is /; /#pcs -> /#add while loading -> the reload stays at /#add.

Review fixes, round 3 (b305d2b)

  • An older link that has both a query and an offer (/s/<id>/?pane=p1&view=terminal#offer=...) keeps its offer on the reload. The offer takes the whole fragment, so the legacy query (a pane or a view) is dropped and never sent again. Repro: with 0, 1 or 2 misses plus Try again, every run shows "Pair with ?", and the reload documents carry no query.

Validation

  • New tests fail on main and pass here: scripts/pages-static.test.ts (a missing /assets/* -> 404 no-store; present -> 200 immutable), scripts/shell-build.test.ts (404 page, ten-character names for code and workers, Caddy file matchers), src/lib/relay/boot.test.ts (reload once, then the notice until a load succeeds; no reload when storage refuses).
  • Browser QA (Chromium, branch dist-shell served through pages-static.ts): missing-once -> one reload, shell loads styled, no crash; always-missing -> one reload, then the notice, no loop; old poisoned entry (HTML, immutable) -> the notice, not the crash screen. The same poisoned entry on v0.5.8 -> crash screen.
  • bun run check fast at b305d2b (old-desktop): workflow syntax, generated types/themes, typecheck, build, unit tests (21992 pass, 0 fail, 50 skip), actionlint: all ok.
  • Android emulator (Chrome 145) against v0.5.8 and this branch: reproduced, and fixed as shown above. Not run: the Play app itself against a 0.5.9 build; the release plan does that before release.

…ll's files, and reload once when the shell fails to load

app.ovis.sh answered a hashed file its deployment lacked with index.html as a 200 under the assets' year-long immutable caching. A phone that asked for shell-2Jhdistb.css during the 0.5.8 deployment kept the page as that stylesheet, the browser refused it (nosniff), and Vite's 'Unable to preload CSS' took the shell to the crash screen on every start.

- assets/404.html: Pages now answers a missing /assets/ file with a 404, and drops any Cache-Control on a 404 for no-store; the Caddy site pins only files that exist.
- The shell's hashed files take ten hash characters, so none reuses an address 0.5.8 served (514 of 604 names were unchanged).
- The relay boot reloads once (sessionStorage guard) when the shell's code fails to load, then shows a small Try again notice instead of the crash screen.
- scripts/pages-static.ts answers a missing file as Pages does (404.html walk, single-page fallback, no-store on 404).
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Missing assets now return a 404 page instead of the app page, with caching disabled for those responses. Existing assets retain immutable caching.
    • If the app fails to load, the page reloads once before showing a connection message and “Try again” option.
  • Localization
    • Added Japanese, Korean, and Simplified Chinese translations for the app load failure message.

The shell build now emits hashed asset names and a missing-asset page. Static Pages handling returns that page with a 404 for missing assets. Relay boot records one reload attempt after a shell load failure, then displays a retry option if loading fails again.

Changes: Shell delivery and load recovery

Layer / File(s) Summary
Hashed assets and missing-asset responses
scripts/shell-build.ts, scripts/shell-build.test.ts
App and worker builds use ten-character hashes. The shell includes assets/404.html; existing assets receive immutable caching, while missing assets receive no-store.
Static Pages path handling
scripts/pages-static.ts, scripts/pages-static.test.ts
Missing paths use the nearest 404.html, then /index.html, or a bare 404. The tests cover missing assets, existing assets, and other missing paths.
One-time shell load recovery
src/lib/relay/boot.ts, src/lib/relay/boot.test.ts, src/components/AppCrash.tsx, src/lib/i18n.{ja,ko,zh}.ts, changelog.d/shell-missing-asset-404.md
Relay boot attempts one reload after a load failure. If loading fails again, it renders AppLoadFailed with a retry button. The message has Japanese, Korean, and Chinese translations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested labels: bug

Merge Risk: Minimal · up to 2801b

This change makes missing shell assets return a 404 instead of cached HTML, uses longer hashed file names, and reloads once before offering "Try again" when the shell fails to load. No concrete merge-blocking problem was found. The planned release-time check of the Play app against a 0.5.9 build should still be done.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main changes: a 404 for a missing /assets/ file, new shell file names, and one reload when the shell fails to load. Each matches the changeset and the PR objectives. The title is l…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template closely. It has a Change section that explains the problem (Android phones stuck on an HTML response cached as CSS for a year), the fix, and resulting b…
Full details: Title check

Explanation

The title names the main changes: a 404 for a missing /assets/ file, new shell file names, and one reload when the shell fails to load. Each matches the changeset and the PR objectives. The title is long at 106 characters, but it stays specific and on topic.

Full details: Description check

Explanation

The description follows the repository template closely. It has a Change section that explains the problem (Android phones stuck on an HTML response cached as CSS for a year), the fix, and resulting behavior. It also has a Validation section listing the checks run (bun run check fast with results, new unit and browser tests, Android emulator repro) and the checks not run (the Play app against a 0.5.9 build). The template asks for a linked issue for features; this is a bug fix, and the PR references PR #4413 rather than an issue, which is a minor gap. HTTP/WS contract-test coverage is not explicitly mentioned, though the change touches HTTP caching headers and the Pages response behavior.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 85f8d6c and 2801b22.

Files selected for processing: 11

  • changelog.d/shell-missing-asset-404.md
  • scripts/pages-static.test.ts
  • scripts/pages-static.ts
  • scripts/shell-build.test.ts
  • scripts/shell-build.ts
  • src/components/AppCrash.tsx
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/relay/boot.test.ts
  • src/lib/relay/boot.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

…its notice in the device's language

Gate review of 2801b22: the guarded reload reloaded the address boot had already stripped, so a pairing offer, a sign-in's return or a query was lost (a pairing link landed on Add a PC). reloadEntry puts the entry address back before reloading; the reloaded page strips it again. AppLoadFailed shows before SettingsProvider set the language, so it reads the saved language itself. pages-static walks the decoded path for 404.html, as Pages does.
…, from the notice too

Gate review of bdffae2: Try again reloaded the stripped address (an offer or a sign-in's return was lost), restoring the raw entry sent a private query to the host again, and a navigation while the shell loaded was undone. reloadAddress keeps the entry's offer or sign-in return, moves a query into the fragment as takeEntryUrl does, and gives no address once the tab navigated; the automatic reload and Try again both use it.
…ell load reloads

Gate review of 7c04735: /s/<id>/?pane=p1&view=terminal#offer=... lost its offer on the reload, because reloadAddress kept only the query in the fragment. The offer takes the whole fragment, so an entry whose fragment is an offer, a sign-in link or a sign-in's return reloads with that fragment and drops the query; the query is never sent again.
@devswha

devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Reviews of record

CodeRabbit reviewed the first head (2801b22, no actionable comments) and skipped the later ones, so the reviews of record for the final head b305d2b are:

Gate findings and how each was resolved:

Round Finding Resolution
2801b22 HIGH: the guarded reload reloaded the address boot had already stripped, so a pairing offer or sign-in return was lost bdffae2: reload at the entry address
2801b22 MEDIUM: the notice showed English before SettingsProvider set the language bdffae2: AppLoadFailed resolves the saved/system language itself (test)
2801b22 LOW: pages-static walked the raw path, not the decoded one bdffae2: decoded, as Pages does
bdffae2 HIGH: Try again reloaded the stripped address 7c04735: Try again uses the same reloadAddress
bdffae2 HIGH: restoring the raw entry sent a private ?file= query to the host again 7c04735: the query moves into the fragment, as takeEntryUrl keeps it
bdffae2 MEDIUM: a navigation while the shell loaded was undone 7c04735: no address restore once the tab navigated
7c04735 MEDIUM: an older link with both a query and an offer lost the offer b305d2b: an offer, sign-in link or sign-in return keeps the fragment, and the query is dropped (never resent)

Each fix has a unit test in src/lib/relay/boot.test.ts, and the gate reviewer reran its Chromium repro on the rebuilt shell.

@devswha
devswha merged commit fb5fae7 into main Nov 21, 2026
15 of 16 checks passed
@devswha
devswha deleted the fix/preload-error branch November 21, 2026 10:42
@devswha

devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head b305d2b75. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit finished, with no review that names this head.

Reviews of record at b305d2b: dori review (omo) CLEAR; omo gate reviewer (GPT-6.2 Astra) CLEAR after 4 rounds, every finding fixed with tests and browser repros (see the review-record comment). CodeRabbit reviewed 2801b22 with no actionable comments and skipped later heads. On the owner's standing rule (two reviews, no Codex) and the lead's word (freeze allow-list, merge when green).

@devswha devswha mentioned this pull request Nov 21, 2026
devswha added a commit that referenced this pull request Nov 21, 2026
Release 0.5.9, on the owner's word (2026-11-21, relayed by the lead:
release once #4377, #4412 and #4416 are merged; he tests on the real
release). Step 2 is on by default from this release (#4377), with the
Add this PC relist fix (#4412) and the relay tab's buttons and one-line
account (#4416). The hosted shell fix for the Android preload failure
(#4413) ships as a new app.ovis.sh build (app.ovis.sh is rolled back to
0.5.7's deployment until then).

- `package.json` and `herdr-plugin.toml`: 0.5.8 -> 0.5.9.
- `REMOTE_BUNDLE_VERSION` 52 -> 53 (`shared/machines.ts`): `server/` and
`shared/` changed since `remote-v52`. After this merges, `remote-v53` is
tagged on the merge commit and the Remote PC bundles run publishes it
before the Release run. Until the Release run is done, nothing touching
`server/`, `shared/`, `bun.lock` or `patches/` merges.
- `CHANGELOG.md`: `bun scripts/changelog-fold.ts 0.5.9` folded the
fragments under 0.5.9 with their PR links. #4412 has no fragment; its
Fixed line was added by hand with its link. No `by @login` credits:
every PR in the section is the maintainer's.
- `release-summaries.json`: 0.5.9 in en, ko, ja and zh: 5 new, 2
improved, 3 fixed. The new lines say what step 2 does for people (sign
in once and the account's PCs open from any device; a 10 s check for a
new device, usually; a notice with Not me on the older devices; PCs not
in an account work as before; how to turn it off with
`OVIS_ACCOUNT_OPENS_ALL=0`). Left out of the summary on purpose (they
stay in the changelog): the desktop app's built-in browser (off by
default), strict mode as one row, and Sign in again in Add this PC's
wait.
- `telemetry/deployed.json` unchanged: release guards agree.

## Validation
- `bun run check fast` on the remote heavy host (hosthatch) at this
release commit on main e00f838: every step ok (unit: 22226 pass, 0
fail, 45 skip).
- `bun test scripts/changelog-fold.test.ts scripts/release-notes.test.ts
server/release-notes.test.ts scripts/release-guards.test.ts`: 60 pass, 0
fail.
- `bun scripts/release-guards.ts --base origin/main`: "Release 0.5.9:
remote bundle, telemetry Worker and release metadata are in order."
- `bun scripts/release-notes.ts 0.5.9` renders the notes (New features
5, Improvements 2, Bug fixes 3).
- Earlier on this branch: an app.ovis.sh incident rollback to 0.5.7's
Pages deployment 44cabf26; this release replaces it with a new build
from release.yml.
- Not run: `check full` (the diff is versions, notes and one constant).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant