Skip to content

Memo skips descendant context updates through lightweight component scopes #1695

Description

@callie-openai

Memo skips descendant context updates through a compiled lightweight component

Verified runtime

Reproduces against raw public Octane source at commit 676a4ee6db59854d6b711921f4ac808845dcdbcd (0.7.1), in both development and production modes. This runtime-only reproduction does not invoke the Octane/TSRX compiler. It executes the accompanying generic JavaScript fixture, using the runtime exports emitted for an independently authored synthetic TSRX example.

The source archive SHA-256 is 88786afc05fb9431e536e8ebf816306d9ec3ac764892cc272340969c14eb08ee. Every Octane source file contributing executable bytes was independently compared with that archive: 37 files in development and 34 in production. All matched exactly. No other dependency contributes executable bytes to the fixture bundle; the resolved devalue dependency and version module are tree-shaken. This is public source evidence, not qualification of the published npm artifact.

Symptom

A context-consuming grandchild below a memoized component keeps the original provider value when the memoized component's props remain stable. The example retains two keyed Activity children and changes the provider identity while switching which child is visible. The identical non-memoized control updates correctly. No Hydrate boundary is necessary.

Active child Provider label Direct view Memoized view
A one one one
A two two one
B three three one
B four four one
A five five one

The original A DOM node is retained in both cases. Runtime warnings/errors are empty.

Runtime-only reproduction

Save runtime-fixture.js and portable-runtime-runner.mjs below together in an otherwise empty directory. Use a checkout or extracted archive of public Octane commit 676a4ee6db59854d6b711921f4ac808845dcdbcd at ../octane. The diagnostic used Node 26.2.0. Install the public runner dependencies locally:

npm init -y
npm install --save-exact [email protected] [email protected] [email protected]
node portable-runtime-runner.mjs ../octane/packages/octane/src/index.ts development results-development
node portable-runtime-runner.mjs ../octane/packages/octane/src/index.ts production results-production

The runner explicitly resolves devalue from its own dependencies because raw Octane source statically imports it. The source checkout needs no dependency installation or compiler build. devalue is resolved but tree-shaken from this fixture's bundle. Output directories must not already exist.

The runner bundles the JavaScript fixture with the specified raw runtime, then uses jsdom and act to exercise the five provider/selection pairs. It saves the exact fixture, bundle, input graph, byte hashes, and observations. No compiler, network, SSR/hydration, or application services are used.

This isolates the runtime; it does not qualify an unmodified public compiler dependency graph.

Source diagnosis and checked repair

The fixture contains a lightweight intermediate component between the memo boundary and the context consumer. LiteBlockImpl does not carry its parent's memoInChain, so the full descendant consumer does not record the memo ancestry needed by lazy context propagation. Separately, refreshContextConsumers walks slot children but misses lightweight child scopes held in children.

A local source repair propagates memoInChain into the lightweight scope and traverses both ordinary and lightweight child scopes, refreshing only independently renderable consumer Blocks. With the identical JavaScript fixture, the repaired runtime passes all five direct and all five memoized observations in both development and production. This does not claim the repair is upstream or that broader framework/application qualification is complete.

runtime-fixture.js
import {
	Activity,
	__s as _$__s,
	activityBlock as _$activityBlock,
	bag1 as _$bag1,
	bag4 as _$bag4,
	child as _$child,
	clone as _$clone,
	componentSlot as _$componentSlot,
	componentSlotLite as _$componentSlotLite,
	componentSlotVoid as _$componentSlotVoid,
	createContext,
	forBlock as _$forBlock,
	ifBlock as _$ifBlock,
	markChildrenBlock as _$markChildrenBlock,
	markWarm as _$markWarm,
	memo,
	registerWarmPlan as _$registerWarmPlan,
	setStringData as _$setStringData,
	sibling as _$sibling,
	template as _$template,
	useContext,
	warmChild as _$warmChild
} from 'octane';

import {
	__createCompiledContext as _$__createCompiledContext,
	bindSignalAttribute as _$bindSignalAttribute,
	bindSignalChild as _$bindSignalChild,
	enableSignalBindings as _$enableSignalBindings
} from 'octane/internal/client';

_$enableSignalBindings(1, true);

const _t$0 = /* @__PURE__ */ _$template("<output></output>");
const _t$1 = /* @__PURE__ */ _$template("<section></section>");
const _t$2 = /* @__PURE__ */ _$template("<article></article>");
const _key$5 = (item) => item.id;

function __then$8(__props, __s, __extra) {
	const __block = __s.block;
	const item = __extra[0];

	_$componentSlot(__s, 0, __block.parentNode, MemoView, { 'id': item.id }, 'c:bb3bef14', __block.endMarker);
}

function __else$10(__props, __s, __extra) {
	const __block = __s.block;
	const item = __extra[0];

	_$componentSlotLite(__s, 0, __block.parentNode, View, { 'id': item.id }, 'c:943ffcf4', __block.endMarker);
}

function __activity$7(__props, __s, __extra) {
	const __block = __s.block;
	const item = __extra[0];
	const props = __extra[1];

	_$ifBlock(__s, 0, __block.parentNode, props.memoized, __then$8, __else$10, __block.endMarker, [item]);
}

function __item$6(item, __s, __extra) {
	const __block = __s.block;
	const props = __extra[0];

	_$activityBlock(__s, 0, __block.parentNode, item.id === props.active ? "visible" : "hidden", __activity$7, __block.endMarker, [item, props]);
}

const __childrenBody = {};

"use octane";

export { createRoot, act } from "octane";

const Identity = /* @__PURE__ */ _$__createCompiledContext({ label: "default" });

const Grandchild = /* @__PURE__ */ _$__s(function Grandchild(props, __s, __extra) {
	const identity = useContext(Identity);
	let _b = __s.slots[0];

	if (_b === undefined) {
		const _root = _$clone(_t$0);

		_b = _$bag4(__s, _root, undefined, _root, null, __s);
	}

	_b.a = _$bindSignalAttribute(__s, _b.a, _b.b, 'data-owner', props.id, "b:484a3b49", _$setStringData);
	_b.e = _$bindSignalChild(__s, _b.e, 1, _b.b, identity.label, 'b:46cbe88e', null, undefined, undefined, undefined, true);
});

const Middle = /* @__PURE__ */ _$__s(/* @__PURE__ */ _$markWarm(
	function Middle(props, __s, __extra) {
		const __warmPlan = Middle.__warm;

		if (typeof __warmPlan === 'function') _$registerWarmPlan(__warmPlan, props); else _$registerWarmPlan(
			() => {
				_$warmChild(Grandchild, { id: props.id });
			},
			void 0
		);

		let _b = __s.slots[0];

		if (_b === undefined) {
			const _root = _$clone(_t$1);

			_b = _$bag1(__s, _root, _root);
		}

		_$componentSlotVoid(__s, 1, _b.a, Grandchild, { 'id': props.id }, 'c:cec1ba06', undefined, true);
	},
	(__wp) => {
		const props = __wp;

		_$warmChild(Grandchild, { id: props.id });
	}
));

const View = /* @__PURE__ */ _$__s(/* @__PURE__ */ _$markWarm(
	function View(props, __s, __extra) {
		const __warmPlan$ = View.__warm;

		if (typeof __warmPlan$ === 'function') _$registerWarmPlan(__warmPlan$, props); else _$registerWarmPlan(
			() => {
				_$warmChild(Middle, { id: props.id });
			},
			void 0
		);

		let _b = __s.slots[0];

		if (_b === undefined) {
			const _root = _$clone(_t$2);

			_b = _$bag1(__s, _root, _root);
		}

		_$componentSlotLite(__s, 1, _b.a, Middle, { 'id': props.id }, 'c:f25f627b');
	},
	(__wp) => {
		const props = __wp;

		_$warmChild(Middle, { id: props.id });
	}
));

const MemoView = /* @__PURE__ */ _$__s(/* @__PURE__ */ memo(View));

export const App = function App(props, __s, __extra) {
	const __block = __s.block;

	function __children$4(__props, __s, __extra) {
		const __block = __s.block;

		_$forBlock(__s, 0, __block.parentNode, props.retained, _key$5, __item$6, 8, [props], null, __block.endMarker);
	}

	_$componentSlotVoid(
		__s,
		0,
		__block.parentNode,
		Identity,
		{
			'value': props.identity,
			'children': _$markChildrenBlock(__children$4, __childrenBody)
		},
		'c:752a64f2',
		__block.endMarker,
		undefined,
		true
	);
};
portable-runtime-runner.mjs
import { createRequire } from 'node:module';
import { readFile, writeFile, mkdir } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import { fileURLToPath, pathToFileURL } from 'node:url';
// Usage: node portable-runner.mjs <runtime-source-entry> <development|production> <new-output-directory>
const [runtimeArgument,runtimeMode,outputArgument]=process.argv.slice(2);
if(!runtimeArgument||!outputArgument||!['development','production'].includes(runtimeMode)) throw Error('Expected runtime, mode and new output directory');
const {resolve,dirname}=await import('node:path');
const base=fileURLToPath(new URL('.',import.meta.url));
const dir=resolve(outputArgument)+'/';await mkdir(dir);
const runtimeEntry=resolve(runtimeArgument);
const require=createRequire(import.meta.url);
const esbuild=require('esbuild');
const source=await readFile(base+'runtime-fixture.js','utf8');
await writeFile(dir+'runtime-fixture.js',source);
const build=await esbuild.build({stdin:{contents:source,resolveDir:base,sourcefile:base+'runtime-fixture.js',loader:'js'},bundle:true,alias:{devalue:require.resolve('devalue'),'octane/internal/client':runtimeEntry.replace(/index\.(ts|js)$/, 'internal/client.$1'),octane:runtimeEntry},format:'esm',platform:'browser',conditions:['browser'],define:{'process.env.NODE_ENV':JSON.stringify(runtimeMode)},metafile:true,outfile:dir+'fixture.bundle.mjs',logLevel:'silent'});
await writeFile(dir+'runtime-graph.json',JSON.stringify(build.metafile,null,2));
const {JSDOM}=require('jsdom');
const dom=new JSDOM('<!doctype html><html><body></body></html>',{url:'https://example.test/',pretendToBeVisual:true});
for(const key of ['window','document','navigator','Node','Element','HTMLElement','Document','DocumentFragment','HTMLInputElement','HTMLTextAreaElement','HTMLSelectElement','HTMLFormElement','HTMLButtonElement','HTMLDialogElement','Text','Comment','MutationObserver','CustomEvent','Event','MouseEvent','KeyboardEvent','DOMException','CSSStyleSheet']) if(dom.window[key]) Object.defineProperty(globalThis,key,{value:dom.window[key],configurable:true});
globalThis.requestAnimationFrame=dom.window.requestAnimationFrame.bind(dom.window);
globalThis.cancelAnimationFrame=dom.window.cancelAnimationFrame.bind(dom.window);
globalThis.getComputedStyle=dom.window.getComputedStyle.bind(dom.window);
globalThis.IS_REACT_ACT_ENVIRONMENT=true;globalThis.IS_OCTANE_ACT_ENVIRONMENT=true;
const errors=[];const originalError=console.error,originalWarn=console.warn;
console.error=(...args)=>errors.push({kind:'error',message:args.map(String).join(' ')});console.warn=(...args)=>errors.push({kind:'warn',message:args.map(String).join(' ')});
const {App,createRoot,act}=await import(pathToFileURL(dir+'fixture.bundle.mjs'));
const retained=[{id:'A'},{id:'B'}],runs=[];
try {
for(const memoized of [false,true]){
 const container=document.createElement('main');document.body.append(container);const root=createRoot(container),rows=[];let a;
 for(const [active,label] of [['A','one'],['A','two'],['B','three'],['B','four'],['A','five']]){
  await act(()=>root.render(App,{memoized,active,identity:{label},retained}));
  const current=container.querySelector(`output[data-owner="${active}"]`);a??=container.querySelector('output[data-owner="A"]');
  rows.push({active,expected:label,actual:current?.textContent??null,passed:current?.textContent===label,sameInitialA:active==='A'?current===a:null,dom:container.innerHTML});
 }
 await act(()=>root.unmount());container.remove();runs.push({memoized,rows,passed:rows.every(r=>r.passed)});
}
} finally { console.error=originalError;console.warn=originalWarn;dom.window.close(); }
const hash=data=>createHash('sha256').update(data).digest('hex');
const inputHashes={};for(const input of Object.keys(build.metafile.inputs)) inputHashes[input]=hash(await readFile(resolve(input)));
const receipt={at:new Date().toISOString(),scope:'Runtime-only synthetic emitted retained keyed Activity direct versus memo grandchild context propagation under jsdom. No compiler invocation.',runtimeMode,runtimeEntrySha256:hash(await readFile(runtimeEntry)),sourceSha256:hash(source),bundleSha256:hash(await readFile(dir+'fixture.bundle.mjs')),runnerSha256:hash(await readFile(fileURLToPath(import.meta.url))),runtimeCoreSha256:hash(await readFile(resolve(dirname(runtimeEntry),runtimeEntry.endsWith('.ts')?'runtime.ts':'runtime.js'))),inputHashes,runs,diagnostics:errors};
await writeFile(dir+'receipt.json',JSON.stringify(receipt,null,2));console.log(JSON.stringify({receipt:dir+'receipt.json',runs:runs.map(r=>({memoized:r.memoized,passed:r.passed,rows:r.rows.map(({dom,...r})=>r)})),diagnostics:errors},null,2));

—Codex

Activity

  1. added a commit that references this issue on Oct 4, 2026
    7b15b4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions