Skip to content

fix(core): lazy-initialize debounced state to prevent computation cycle#67715

Open
alxhub wants to merge 1 commit intoangular:mainfrom
alxhub:sf/bug-debounced
Open

fix(core): lazy-initialize debounced state to prevent computation cycle#67715
alxhub wants to merge 1 commit intoangular:mainfrom
alxhub:sf/bug-debounced

Conversation

@alxhub
Copy link
Member

@alxhub alxhub commented Mar 17, 2026

When building a debounced resource, we previously eagerly started tracking the 'source' signal state by instantiating a regular signal. However, if this 'debounced' primitive is initialized in a computation reactive graph (like signal forms 'validateAsync'), reading the current UI source dependency eagerly can induce a cycle if we haven't finished calculating the graph node yet.

This fix uses a 'linkedSignal' block to define the eager 'source' instead. Because linkedSignals are lazy by default, this bypasses the initial eager evaluation, allowing the containing reactive graph to finish forming first without losing our timing logic inside the ambient effect().

When building a debounced resource, we previously eagerly started tracking the 'source' signal state by instantiating a regular signal. However, if this 'debounced' primitive is initialized in a computation reactive graph (like signal forms 'validateAsync'), reading the current UI source dependency eagerly can induce a cycle if we haven't finished calculating the graph node yet.

This fix uses a 'linkedSignal' block to define the eager 'source' instead. Because linkedSignals are lazy by default, this bypasses the initial eager evaluation, allowing the containing reactive graph to finish forming first without losing our timing logic inside the ambient effect().
@alxhub alxhub added target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Mar 17, 2026
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Mar 17, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant