Skip to content

Commit db6de87

Browse files
committed
fix(signals): use wrapper check instead of nullish coalescing in optimistic read()
The read() method used `?.value ??` which treats an overlay value of `undefined` as missing and falls through to `source.get()`. This is inconsistent with latest() and snapshot(), which correctly test the wrapper object. An optimistic set to `undefined` would be silently ignored on read, and a pending source could suspend instead of showing the last overlay view.
1 parent fa8d353 commit db6de87

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ class OptimisticManager<T> {
113113

114114
read(exclude?: Operation): T {
115115
const snapshot = this.source.snapshot();
116-
return this.overlay(snapshot, exclude)?.value ?? this.source.get();
116+
const overlaid = this.overlay(snapshot, exclude);
117+
return overlaid ? overlaid.value : this.source.get();
117118
}
118119

119120
latest<F>(fallback?: F, exclude?: Operation): T | F | undefined {

0 commit comments

Comments
 (0)