Skip to content

fix: avoid false infinite loop detection when cached signal self-updates#24412

Draft
Artur- wants to merge 4 commits into
mainfrom
claude/slack-session-DHaiW
Draft

fix: avoid false infinite loop detection when cached signal self-updates#24412
Artur- wants to merge 4 commits into
mainfrom
claude/slack-session-DHaiW

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 22, 2026

Summary

  • Add a ThreadLocal flag in Effect to track when we're in a "read-triggered update" context
  • Wrap the cached signal's self-update submit() call in this context
  • Skip infinite loop detection when this flag is set, since it's lazy evaluation rather than an actual write loop

Background

When an effect reads from a cached signal that detects its value is stale (via hasChanges()), the cached signal recomputes its value and submits an update. This update triggers a change notification back to the effect. Previously, this was incorrectly detected as an infinite loop because the effect was still active when the notification arrived.

However, this is not a true infinite loop - it's lazy evaluation happening during a read operation. The effect is reading, not writing, so there's no actual loop.

Test plan

  • Add unit test infiniteLoopDetection_cachedSignalSelfUpdate_notDetectedAsLoop to verify an effect reading a cached signal that self-updates does not throw an infinite loop exception
  • Run existing tests to ensure no regressions in actual infinite loop detection

Fixes #24409

https://claude.ai/code/session_0193Z8ydgjUCCpbgCZwHhGGM


Generated by Claude Code

When an effect reads from a cached signal that detects its value is stale,
the cached signal recomputes and submits an update. This previously
triggered infinite loop detection because the notification happened while
the effect was still active. However, this is lazy evaluation (read-triggered),
not an actual write loop.

Add a ThreadLocal flag to track when we're in a "read-triggered update"
context and skip the infinite loop check in that case.

Fixes #24409

https://claude.ai/code/session_0193Z8ydgjUCCpbgCZwHhGGM
@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented May 22, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link
Copy Markdown

cla-assistant Bot commented May 22, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

Test Results

 1 420 files  ±0   1 420 suites  ±0   1h 19m 27s ⏱️ - 4m 17s
10 000 tests +1   9 932 ✅ +1  68 💤 ±0  0 ❌ ±0 
10 472 runs  +1  10 403 ✅ +1  69 💤 ±0  0 ❌ ±0 

Results for commit 7f8e48f. ± Comparison against base commit 7c1186a.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signal infinite loop detection is triggered if a cached signal is invalidated by reading it

2 participants