Repository navigation
fix(compiler): see imported member reads through TypeScript wrappers - #2310
Merged
Merged
Conversation
containsImportedMemberRead walked a member chain's receivers with `object.object` and stopped at the first node that was not a member expression. A receiver wrapped in `!`, `as`, or `satisfies` ended the walk before the imported identifier, so a read like `flags!.enabled` looked free of live imports. In production builds a keyed @for row reading one could take the identity-only survivor skip, and the whole list could be cached on `[props.items, flags]`, so the row kept a stale @if branch after the member changed. The walk now unwraps each receiver with unwrapValueExpression. Reported by Cursor Bugbot on #1213: #1213 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler
marked this pull request as ready for review
October 29, 2026 20:55
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 08f2608 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 08:56 PM |
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 08f2608 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 08:56 PM |
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
In production builds, an imported object's member read through a TypeScript wrapper could be missed by the live-import check.
flags!.enabled,(flags as Flags).enabledand(flags satisfies Flags).enabledall slipped past it. A keyed@forrow that reads one could then keep showing a stale branch after the member changed. The plainflags.enabledform was already handled.Cursor Bugbot reported this on #1213 (#1213 (comment)), and the finding was never addressed. The code it points at is unchanged on main.
Why
containsImportedMemberReadinpackages/octane/src/compiler/compile.jswalks a member chain down to its base identifier, followingobject.object. It stopped at the first node that wasn't a member expression, so inflags!.enabledit reached theTSNonNullExpressionand never sawflags.Every gate that guards against live imports calls this function. Compiled on main with
dev: false, this row is wrong in two ways:forBlockflags argument is27, which sets the PURE bit. A surviving row with the same identity skips its body.compilerMemoRegionwhose dependencies are[props.items, flags].flagsnever changes identity, so re-rendering with the sameitemsskips the list entirely.With
flags.enabled, the same component gets flags26and no memo region.Changes
containsImportedMemberRead: unwraps each receiver with the existingunwrapValueExpression, which stripsas,!,satisfies,<T>x, parentheses and optional chains, before it continues the walk.octane.I also checked the compiler's other member-chain walks. One walks JSX tag names, which can't contain these wrappers. The other,
hydrationLayoutReadCapture, returnsnullfor any shape it doesn't recognize.isDeferredRefReadkeys on the.currentproperty, soref!.currentis still caught.Validation
pnpm format:check: not run repo-wide.pnpm format:filesleaves all four changed files unchanged.pnpm typecheck: not run. The change is plain JS in the compiler plus tests.pnpm test: not run in full locally.for-item-purity.test.ts: the imported-member case becomes anit.eachover the bare form and five wrapped forms:!,as,satisfies,aswith?., and a wrapper in the middle of the chain. Each must leave the PURE bit clear.auto-memo.test.ts: a runtime case for each of!,asandsatisfies. It mounts adev: falsebuild of a keyed list whose rows readflagsfrom an injected./flagsmodule, then:flags.enabled = trueand re-renders with the same list, expecting two<b>elements;falseand re-renders with a new array of the same rows, expecting zero.<b>elements render where two are expected.vitest run --project octane --project octane-prod packages/octane/tests/compiler packages/octane/tests/auto-memo.test.ts packages/octane/tests/for.test.ts: 5,260 passed and 6 failed.css-module-vite,strong-html,volarandweb-typescript-output.pnpm sync: generated nothing.Risk / follow-ups
Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Compiler-only change that disables over-aggressive memoization for a narrow pattern; behavior becomes more correct without touching auth, data, or runtime APIs.
Overview
Production keyed
@forrows could stay memoized/skipped when an@iftest read an imported object through a TypeScript wrapper (flags!.enabled,(flags as Flags).enabled,(flags satisfies Flags).enabled, etc.), even though the underlying member could change while the import binding’s identity stayed the same. Plainflags.enabledwas already detected.containsImportedMemberReadnow peels those wrappers viaunwrapValueExpressionwhile walking each member chain’s receiver, so the same live-import gates apply and those rows/lists re-render when the member updates.Compiler tests cover more wrapped read shapes in
for-item-purity, andauto-memoaddsdev: falseruntime cases for!,as, andsatisfies. Patch changeset foroctane.Reviewed by Cursor Bugbot for commit 08f2608. Bugbot is set up for automated code reviews on this repo. Configure here.