Repository navigation
feat: reject ambient browser reads in Strong renders - #1036
Merged
domgan-oai merged 1 commit intoSep 10, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
domgan-oai
marked this pull request as ready for review
September 10, 2026 16:29
27 of 35 tasks
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
OCTANE_STRONG_RENDER_AMBIENT_READfor render-time browser-global reads in Strong modules.octaneand@octanejs/mcp-server.Part of #1027 (ambient globals item).
Why
Reading live browser state during a cached render can produce stale output and break server rendering. The diagnostic points to
useSyncExternalStorewith a server snapshot, an effect, or a lazy initializer with server-rendering guards.Changes
window,document,localStorage,sessionStorage,navigator,location, andmatchMedia, includingtypeofreads and known browser-handle aliases.globalThisproperties, destructuring, object/JSX spreads, JSX member tags, and compound/update reads. Permit the global object identity and known standard JavaScript language builtins.awaitevaluation order, local shadowing, and module constant declaration order.Validation
pnpm typecheck.pnpm exec vitest run packages/octane/tests/compiler --silent=passed-only— 55 files passed, 2,047 tests passed and 14 expected failures at the final source revision; six further regression cases then passed in the targeted run.git diff --check.pnpm sync— no additional generated changes.afdc3618a: 100/1,000-component normal, legal ambient-callback, and module-alias workloads in Strong and compatibility modes. All 24 client/server output comparisons matched bytes and SHA256.Compiler throughput
Node v26.4.0 on Apple M5 Max; one process alternated baseline/candidate order with 3 warmups and 17 pairs (100 components) or 11 pairs (1,000). Final candidate
90c024d3d, analyzer SHA256a3eb2c64d86e26d93fe15715dc70de1b5168c6d2ca2144c9ca6a228ab63ff387.Paired median ratios were 0.972–1.036. Compatibility control medians ranged from −5.8% to +1.8%; sample tails were noisier than the observed deltas. No material throughput regression was established; small compiler overhead remains plausible. Generated runtime code was identical in the measured legal programs.
Local reproduction artifacts:
/private/tmp/octane-ambient-paired.mjsand/private/tmp/octane-ambient-paired-final.json; command:node /private/tmp/octane-ambient-paired.mjs /private/tmp/octane-ambient-paired-final.json.90c024d3d: all test and React parity shards, browser and website integration, package validation, examples, lint, typecheck, and provenance. Cursor Bugbot passed with no findings. The PR is ready for review; maintainer approval is still required.The full repository
pnpm testand repository-wide format scan were not run locally; the compiler suite and changed-file formatting cover this change, and full relevant CI will be checked before handoff.Risk / follow-ups
constaliases are resolved independently of declaration order.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Strong modules that previously read browser APIs during render will now fail at compile time; alias analysis is intentionally bounded and may miss or over-approximate some patterns.
Overview
Strong mode now fails compile when render code reads live browser globals, with a new
OCTANE_STRONG_RENDER_AMBIENT_READdiagnostic.The Strong compiler pass tracks unshadowed
window,document, storage,navigator,location,matchMedia, and mostglobalThisproperty access (includingtypeof, aliases, destructuring, spreads, and JSX), while still allowing shadowed names, module-level scalar snapshots, theglobalThisobject itself, and standard language builtins. LazyuseState/useReducerinitializers,useSyncExternalStoresnapshot callbacks, and deferred work stay exempt.Docs, MCP skill text, a changeset, and a large
strong-mode.test.tssuite documentuseSyncExternalStorewith a server snapshot and pin client/server emission parity plus Volar source locations.Reviewed by Cursor Bugbot for commit 90c024d. Bugbot is set up for automated code reviews on this repo. Configure here.