Skip to content

Commit 34083ca

Browse files
committed
fix(octane): skip view allocation in presentDefinition under read barrier
When a binding is frozen or owner.readBarrier is set, presentDefinition was creating a private view whose evaluate would return pendingState (since the new view node has no prior state). This hid the committed cell's ready value during hydration or historical re-renders. Return undefined early in both DerivedBinding and ScalarBinding presentDefinition when frozen or under a read barrier. This keeps the committed cell presenting its existing state, and installDefinition rebinds the compute when the render settles.
1 parent 5007de8 commit 34083ca

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

‎packages/octane/src/signals/computations.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class DerivedBinding<T> extends RedeclarableBinding<DerivedCompute<T>> {
175175

176176
protected presentDefinition(compute: DerivedCompute<T>): ScopedNode | undefined {
177177
if (this.asynchronous) return undefined;
178+
if (this.frozen || this.owner.readBarrier !== undefined) return undefined;
178179
// A zero-argument computation runs once here. An equal synchronous value
179180
// needs no view; any other result seeds the view, so the closure never
180181
// runs twice and asynchronous work never starts twice.

‎packages/octane/src/signals/scalar-computations.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class ScalarBinding<T>
8888

8989
/** An equal value needs no view; a changed one is evaluated once, privately. */
9090
protected presentDefinition(compute: DerivedCompute<T>): ScopedNode | undefined {
91+
if (this.frozen || this.owner.readBarrier !== undefined) return undefined;
9192
let probe: { value: T; reads: ScopedNode[] } | undefined;
9293
if (!this.frozen && this.owner.readBarrier === undefined) {
9394
try {

0 commit comments

Comments
 (0)