fix(platform-browser): avoid circular DI error in async renderer by josephperrott · Pull Request #59271 · angular/angular · GitHub
Skip to content

fix(platform-browser): avoid circular DI error in async renderer - #59271

Closed
josephperrott wants to merge 1 commit into
angular:19.0.xfrom
josephperrott:patch-for-59256
Closed

josephperrott wants to merge 1 commit into
angular:19.0.xfrom
josephperrott:patch-for-59256

Conversation

@josephperrott

Copy link
Copy Markdown
Member

Patch version of #59256

In angular/components#30179 the CDK overlay started depending on the `Renderer2Factory`. Since the overlay is used in the `MatSnackbar` which is commonly used in error handlers, `Overlay` can end up being injected as a part of the app initialization. Because `AsyncAnimationRendererFactory` depends on the `ChangeDetectionScheduler`, it may cause a circular dependency.

These changes inject the `ChangeDetectionScheduler` lazily to avoid the error.

Note: this will also be resolved by angular#58984, but I decided to send it out, because:
1. angular#58984 seems to be stuck on some internal cleanup.
2. The `AsyncAnimationRendererFactory` doesn't need the `scheduler` eagerly anyway so the change is fairly safe.

Fixes angular#59255.
@josephperrott josephperrott added action: merge The PR is ready for merge by the caretaker area: animations legacy animations package only. Otherwise use area: core. target: patch This PR is targeted for the next patch release labels Dec 20, 2024
@ngbot ngbot Bot added this to the Backlog milestone Dec 20, 2024
@josephperrott

Copy link
Copy Markdown
Member Author

josephperrott pushed a commit that referenced this pull request Dec 21, 2024
)

In angular/components#30179 the CDK overlay started depending on the `Renderer2Factory`. Since the overlay is used in the `MatSnackbar` which is commonly used in error handlers, `Overlay` can end up being injected as a part of the app initialization. Because `AsyncAnimationRendererFactory` depends on the `ChangeDetectionScheduler`, it may cause a circular dependency.

These changes inject the `ChangeDetectionScheduler` lazily to avoid the error.

Note: this will also be resolved by #58984, but I decided to send it out, because:
1. #58984 seems to be stuck on some internal cleanup.
2. The `AsyncAnimationRendererFactory` doesn't need the `scheduler` eagerly anyway so the change is fairly safe.

Fixes #59255.

PR Close #59271
@josephperrott
josephperrott deleted the patch-for-59256 branch December 21, 2024 18:28
@angular-automatic-lock-bot

Copy link
Copy Markdown

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: animations legacy animations package only. Otherwise use area: core. target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants