Skip to content

fix(common): remove placeholder image listeners once view is removed #61621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arturovt
Copy link
Contributor

Prior to this commit, attempting to resolve a ChangeDetectorRef after views or app have been destroyed would result in an error. In this commit, we clean up listeners once the view is destroyed, before the placeholder loads or fails to load.

Prior to this commit, attempting to resolve a `ChangeDetectorRef` after views or app have been destroyed would result in an error. In this commit, we clean up listeners once the view is destroyed, before the placeholder loads or fails to load.
@pullapprove pullapprove bot requested a review from alxhub May 22, 2025 17:17
@angular-robot angular-robot bot added the area: common Issues related to APIs in the @angular/common package label May 22, 2025
@ngbot ngbot bot added this to the Backlog milestone May 22, 2025
@arturovt
Copy link
Contributor Author

arturovt commented Jun 5, 2025

@AndrewKushnir cc

@AndrewKushnir AndrewKushnir requested review from AndrewKushnir and removed request for alxhub June 5, 2025 17:58
@AndrewKushnir AndrewKushnir added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 5, 2025
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this commit, attempting to resolve a ChangeDetectorRef after views or app have been destroyed would result in an error.

@arturovt could you please provide a bit more info on this - when does it happen? I'm also wondering it it might be possible to have a test to capture this behavior?

@arturovt
Copy link
Contributor Author

arturovt commented Jun 5, 2025

The most basic showcase:

// server.ts
app.get('/cat-blurred.jpg', async (req, res) => {
  await new Promise((resolve) => setTimeout(resolve, 4000));
  res.sendFile('/cat-blurred-file.jpg');
});
<img ngSrc="cat.jpg" width="400" height="200" placeholder="cat-blurred.jpg" />
<button (click)="appRef.destroy()">Destroy</button>

@arturovt
Copy link
Contributor Author

arturovt commented Jun 5, 2025

Technically, it only removes event listeners when the view is destroyed, which is a common code path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: common Issues related to APIs in the @angular/common package target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants