Skip to content

fix: Compare a copied input by the settle count of the value it holds - #1251

Merged
philippjfr merged 2 commits into
mainfrom
fix/clone-settle-state
Nov 24, 2026
Merged

philippjfr merged 2 commits into
mainfrom
fix/clone-settle-state

Conversation

@philippjfr

@philippjfr philippjfr commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Since #1210, a pipe could end up permanently stale when one of its arguments is a reference bound to the same source. In this case out stayed at (1, ('B', 2)) after src changed to 2:

src = rx(1)
p = P(x=param.bind(lambda v: ('B', v), src))
out = src.rx.pipe(lambda sv, xv: (sv, xv), p.param.x.rx())
out.rx.watch(print)
src.rx.value = 2

out's previous node is a copy of src. When src changes, the bound reference updates first and makes out recompute while the copy still holds 1. _settle_state reported the settle count of src itself, which had already moved to 2, so out recorded that it had seen the new src. When src's own change reached out, nothing looked new and the recompute was skipped.

A clean copy now reports the source's settle count for the value it holds: the count at which it adopted the value, or at which it was created. out recomputes once src's change arrives, so it ends at (2, ('B', 2)) again, as in 2.4.2. The intermediate call with the old src value is the same glitch 2.4.2 has.

I added a regression test that fails without the change. The full test suite passes.

All four variants of the reported case, before and after
Case 2.4.2 main this PR
sync ref, p.param.x.rx() glitch, then correct stale (1, ('B', 2)) glitch, then correct
sync ref, p.param.x glitch, then correct glitch, then correct glitch, then correct
async ref, p.param.x.rx() glitch, then correct one correct call one correct call
async ref, p.param.x glitch, then correct glitch, then correct glitch, then correct

AI Disclosure

Tool & Model: Claude Code + Claude Opus 5.5
Usage: Bisected the regression to #1210, traced the settle counts and wrote the fix and test.

  • I have tested all AI-generated content in my PR.
  • I take responsibility for all AI-generated content in my PR.

Assisted-by: Claude Code:claude-opus-5-5
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.79%. Comparing base (5b213f1) to head (c237b42).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1251   +/-   ##
=======================================
  Coverage   89.78%   89.79%           
=======================================
  Files          10       10           
  Lines        7078     7082    +4     
=======================================
+ Hits         6355     6359    +4     
  Misses        723      723           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@philippjfr
philippjfr merged commit 02c54b7 into main Nov 24, 2026
18 checks passed
@philippjfr
philippjfr deleted the fix/clone-settle-state branch November 24, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant