fix(core): defer afterRenderEffect sequences registered while hooks run by arturovt · Pull Request #70581 · angular/angular · GitHub
Skip to content

fix(core): defer afterRenderEffect sequences registered while hooks run - #70581

Open
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/after-render-reentrant-sequence-registration
Open

fix(core): defer afterRenderEffect sequences registered while hooks run#70581
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/after-render-reentrant-sequence-registration

Conversation

@arturovt

@arturovt arturovt commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

AfterRenderImpl.addSequence added the sequence straight to sequences without checking whether hooks were already running. If a view was change-detected from inside a render hook (for example, when a custom element connects to the DOM during a render phase), its afterRenderEffect sequence could be added mid-pass. The phase loop would then run its later phases in the current pass and skip the earlier ones, so earlyRead could run a tick after write. This also shifted the phase callback arguments and eventually caused TypeError: fn is not a function when the view was destroyed.

Defer these registrations to the next pass, like register already does for sequences registered outside a view.

Fixes #61715

`AfterRenderImpl.addSequence` added the sequence straight to `sequences` without checking whether hooks were already running. If a view was change-detected from inside a render hook (for example, when a custom element connects to the DOM during a render phase), its `afterRenderEffect` sequence could be added mid-pass. The phase loop would then run its later phases in the current pass and skip the earlier ones, so `earlyRead` could run a tick after `write`. This also shifted the phase callback arguments and eventually caused `TypeError: fn is not a function` when the view was destroyed.

Defer these registrations to the next pass, like `register` already does for sequences registered outside a view.

Fixes angular#61715
@pullapprove
pullapprove Bot requested a review from JeanMeche September 5, 2026 18:00
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Sep 5, 2026
@ngbot ngbot Bot added this to the Backlog milestone Sep 5, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(form-field): Uncaught exception when used inside custom element "TypeError: fn is not a function" [ver >= 20.0.0-rc.1]

1 participant