ReviewOS

stacks/stx

Identify speculative router requests by their request purpose

#2146
Closed chris opened this 10 hours ago ·
10 hours ago

The router's low-priority speculative fetches are currently indistinguishable from ordinary application Fetch requests in DevTools. In real ReviewOS acceptance, /me had finished rendering with no HTTP/console errors while twelve visible-link prefetches kept the network busy past 30 seconds. The fragment-to-document fetch for another layout is intentional; existing concurrency/cache behavior should stay intact.

Mark all speculative router HTML requests, including layout fallback, public prefetch and background revalidation, with explicit request-purpose metadata (Purpose: prefetch). Normal navigation/refresh requests must remain ordinary requests. Cover both protocol paths and user navigation, publish normally and verify from actual installed packages. Pair this with purpose-aware browser observation in Stacks; preserve raw network diagnostics and all HTTP/error audits.

Consumer finding and actual CI evidence: https://github.com/stacksjs/hq.training/issues/391 . Launch tracker: https://github.com/stacksjs/hq.training/issues/346 . The earlier first-paint/concurrency work is related but already present: https://github.com/stacksjs/stacks/issues/3082 .

10 hours ago

Consumer and testing framework: /stacks/hq.training/issues/391 and /stacks/stacks/issues/3093. Background prefetching remains enabled with existing concurrency; ordinary navigation remains unmarked.

10 hours ago

Verified against latest main 81294bc76cc0c86a6ec481e37a292c3d5fa10e49: this is already implemented by @chrisbbreuer in dce366809f5cf959d674af05852a076c674fc007, released in v0.2.784. No duplicate implementation or new release needed.

The shared header builder declares Purpose: prefetch for link warming, cross-layout full-document fallback, background revalidation, and public router.prefetch(). Ordinary navigation and explicit refresh remain unmarked; queue/concurrency/request-sharing behavior remains intact.

Verification:

  • Full router suite on latest main: 420 passed, 0 failed, 910 assertions across 55 files.
  • Fix CI and release-commit CI passed all five jobs: source CI, release CI.
  • Fresh public npm installation of stx-router@0.2.784: 12 passed, 0 failed, 42 assertions. Executed the maintained packages/router/test/client-layout-prefetch.test.ts against installed stx-router/client, plus protocol-matrix checks for public fragment/document prefetch, fragment revalidation, and unmarked explicit refresh.
  • Negative control using the published 0.2.783 client: all five selected purpose-header tests fail as expected; restoring installed 0.2.784 passes all 12.
  • Downloaded the original 0.2.784 npm archive and verified SHA-512 against registry integrity (85,033 bytes).

Craft and the user-owned Map test modification were left untouched. Stacks' purpose-aware browser observation remains tracked separately in stacksjs/stacks#3093.

10 hours ago

Implemented in https://github.com/stacksjs/stx/commit/dce366809f5cf959d674af05852a076c674fc007 and published normally as 0.2.784: https://github.com/stacksjs/stx/releases/tag/v0.2.784. Link warming, cross-layout document fallback, background revalidation and public prefetch calls declare Purpose: prefetch; ordinary navigation stays unmarked. Existing prefetch scheduling/request sharing are preserved.

All420 router tests pass locally. Exact-source, macOS signing and npm core publication jobs passed in https://github.com/stacksjs/stx/actions/runs/41427539588 (the independent icons job is outside this fix). The matching observer is published in Stacks0.75.422: /stacks/stacks/issues/3093.

Actual HQ consumption: https://github.com/stacksjs/hq.training/commit/deb493f899a5fe7a4508a98bc2feecf3a0af7978. The frozen public install, exact Bun1.4.4, HQ types and strict lint (2,677 files, zero errors/warnings) pass. Eleven regressions run against the actual public router/testing packages pass (50 assertions), including real Chrome: a held ordinary request still blocks, a declared prefetch remains in raw diagnostics while foreground readiness can finish, and failed speculative HTTP requests, duplicate API calls and console errors still fail the audit. Public log SHA-256: adea21e036ba438efdf8535717ba4f6e2ddea73b6853488faa7457f21b13c3e1. No dependency payload patches or local source overrides.

HQ integration/production acceptance remains open at /stacks/hq.training/issues/391 and /stacks/hq.training/issues/346; the new normal forge run is https://reviewos.org/stacks/hq.training/run/2604. TestFlight146 is being built, not yet claimed delivered. Native device acceptance remains separately tracked and capacity blocked.

Sign in to comment on this issue.