Skip to content

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

Closed
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:59255/async-renderer
Closed

fix(platform-browser): avoid circular DI error in async renderer#59256
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:59255/async-renderer

Conversation

@crisbeto
Copy link
Copy Markdown
Member

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. refactor(core): Instantiate the ErrorHandler lazily. #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.

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.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Dec 20, 2024
@crisbeto crisbeto requested a review from JeanMeche December 20, 2024 09:53
@crisbeto
Copy link
Copy Markdown
Member Author

Passing TGP

@AndrewKushnir AndrewKushnir added area: animations animations: async Issues related to async animation loading and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 20, 2024
@ngbot ngbot bot modified the milestone: Backlog Dec 20, 2024
@AndrewKushnir AndrewKushnir removed the request for review from JeanMeche December 20, 2024 22:02
@josephperrott josephperrott added action: merge The PR is ready for merge by the caretaker 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 Dec 20, 2024
@josephperrott
Copy link
Copy Markdown
Member

This PR was merged into the repository by commit 8c5db3c.

The changes were merged into the following branches: main

@josephperrott
Copy link
Copy Markdown
Member

@crisbeto merged into minor and not patch, from looking at the change against patch, I created #59271 for patch version of the change

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 20, 2025
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
…ular#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.

PR Close angular#59256
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 animations: async Issues related to async animation loading area: animations target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Circular dependency in DI detected for ChangeDetectionScheduler in 19.0.4

3 participants