René's URL Explorer Experiment


Title: elements: too many change detection runs during initialization · Issue #33059 · angular/angular · GitHub

Open Graph Title: elements: too many change detection runs during initialization · Issue #33059 · angular/angular

X Title: elements: too many change detection runs during initialization · Issue #33059 · angular/angular

Description: 🐞 bug report Affected Package The issue is caused by package @angular/elements. Is this a regression? No. Description During custom element initialization (i.e. initializeComponent()), the default NgElementStrategy, ComponentNgElementStr...

Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/elements. Is this a regression? No. Description During custom element initialization (i.e. initializeComponent()), the default ...

X Description: 🐞 bug report Affected Package The issue is caused by package @angular/elements. Is this a regression? No. Description During custom element initialization (i.e. initializeComponent()), the default ...

Opengraph URL: https://github.com/angular/angular/issues/33059

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"elements: too many change detection runs during initialization","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\n\r\nThe issue is caused by package @angular/elements.\r\n\r\n\r\n### Is this a regression?\r\n\r\nNo.\r\n\r\n\r\n### Description\r\n\r\nDuring custom element initialization (i.e. [initializeComponent()][1]), the default `NgElementStrategy`, [ComponentNgElementStrategy][2], (transitively) may call [setInputValue()][3], which in turn calls [scheduleDetectChanges()][4]. Right after, `initializeComponent()` calls [detectChanges()][5].\r\n\r\nHowever, despite CD being run synchronously after `setInputValue()`, the scheduled, asynchronous CD (scheduled inside `setInputValue()`) will still run.\r\n\r\nThis results in two CDs per Angular custom element instance, which can negatively affect initial page loads or route transitions for pages/routes with many custom elements. (This is the case for example in https://angular.io/guide/router, which has ~200 custom elements.)\r\n\r\n**Possible solution:**\r\nI think it would be reasonable to cancel scheduled CD, if CD is triggered earlier than scheduled.\r\n\r\n(See the reproduction below for a demo of the fix.)\r\n\r\n\r\n### 🔬 Minimal Reproduction\r\n\r\nhttps://stackblitz.com/edit/ngelements-issue-33059?file=src/app/app.component.ts\r\n\r\n\r\n### Anything else relevant?\r\n\r\nRelated issues: #23813, #33060\r\n\r\n\r\n[1]: https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L146-L162\r\n[2]: https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L45\r\n[3]: https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L168\r\n[4]: https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L139\r\n[5]: https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L158\r\n","author":{"url":"https://github.com/gkalpak","@type":"Person","name":"gkalpak"},"datePublished":"2019-10-09T15:30:08Z","url":"https://github.com/angular/angular/issues/33059"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bb457dfe-7675-610a-25c6-447471bc5953
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAC74:14ECB:16DAEC4:1D029C6:6B0137BB
html-safe-noncecafe74d5d6f2fa5f3252eff4f21f4a06ae2b23b18df1215f5a5ce64a13ff320e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzc0OjE0RUNCOjE2REFFQzQ6MUQwMjlDNjo2QjAxMzdCQiIsInZpc2l0b3JfaWQiOiI0NTg3ODc2Nzc0NTI3OTczMzA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac384b587dfc1acd42d6c348b601ea60f505c8f847918b9d767d484d76977a9d81
hovercard-subject-tagissue:504728208
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/33059/issue_layout
twitter:imagehttps://opengraph.githubassets.com/605d80ab0a9eaca4bd8dfa594fac55979efe429e9537d9a12105fe5a8244d86a/angular/angular/issues/33059
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/605d80ab0a9eaca4bd8dfa594fac55979efe429e9537d9a12105fe5a8244d86a/angular/angular/issues/33059
og:image:alt🐞 bug report Affected Package The issue is caused by package @angular/elements. Is this a regression? No. Description During custom element initialization (i.e. initializeComponent()), the default ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegkalpak
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/33059#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F33059
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F33059
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/33059
Reloadhttps://github.com/angular/angular/issues/33059
Reloadhttps://github.com/angular/angular/issues/33059
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues836 (836)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/33059
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/33059
elements: too many change detection runs during initializationhttps://github.com/angular/angular/issues/33059#top
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
area: performanceIssues related to performancehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20performance%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Oct 9, 2019https://github.com/angular/angular/issues/33059#issue-504728208
initializeComponent()https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L146-L162
ComponentNgElementStrategyhttps://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L45
setInputValue()https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L168
scheduleDetectChanges()https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L139
detectChanges()https://github.com/angular/angular/blob/9f0c549bc/packages/elements/src/component-factory-strategy.ts#L158
https://angular.io/guide/routerhttps://angular.io/guide/router
https://stackblitz.com/edit/ngelements-issue-33059?file=src/app/app.component.tshttps://stackblitz.com/edit/ngelements-issue-33059?file=src/app/app.component.ts
#23813https://github.com/angular/angular/issues/23813
#33060https://github.com/angular/angular/issues/33060
gkalpakhttps://github.com/gkalpak
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
area: performanceIssues related to performancehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20performance%22
on Oct 9, 2019https://github.com/angular/angular/issues/33059#event-2699503248
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Oct 9, 2019https://github.com/angular/angular/issues/33059#event-2699503292
https://github.com/pkozlowski-opensource
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
on Oct 9, 2019https://github.com/angular/angular/issues/33059#issuecomment-540115008
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Oct 9, 2019https://github.com/angular/angular/issues/33059#issuecomment-540126728
https://github.com/pkozlowski-opensource
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
on Oct 9, 2019https://github.com/angular/angular/issues/33059#issuecomment-540128612
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
triage #1https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22triage%20%231%22
on May 29, 2020https://github.com/angular/angular/issues/33059#event-3386642606
https://github.com/pkozlowski-opensource
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
on May 29, 2020https://github.com/angular/angular/issues/33059#issuecomment-635905056
https://github.com/angelaman
angelamanhttps://github.com/angelaman
on Jun 9, 2020https://github.com/angular/angular/issues/33059#issuecomment-641610136
petebacondarwinhttps://github.com/petebacondarwin
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
on Oct 19, 2020https://github.com/angular/angular/issues/33059#event-3894314837
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Oct 19, 2020https://github.com/angular/angular/issues/33059#event-3894315342
https://github.com/glued
gluedhttps://github.com/glued
on Jan 7, 2021https://github.com/angular/angular/issues/33059#issuecomment-756433202
AndrewKushnirhttps://github.com/AndrewKushnir
triage #1https://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22triage%20%231%22
on Mar 15, 2022https://github.com/angular/angular/issues/33059#event-6239501611
https://github.com/pkozlowski-opensource
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
on Apr 12, 2023https://github.com/angular/angular/issues/33059#issuecomment-1505047690
#33060https://github.com/angular/angular/issues/33060
https://github.com/arturovt
arturovthttps://github.com/arturovt
on Sep 29, 2026https://github.com/angular/angular/issues/33059#issuecomment-5899485035
@JeanMechehttps://github.com/JeanMeche
https://github.com/atscott
atscotthttps://github.com/atscott
on Nov 20, 2026https://github.com/angular/angular/issues/33059#issuecomment-7030195130
#56728https://github.com/angular/angular/pull/56728
atscotthttps://github.com/atscott
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 20, 2026https://github.com/angular/angular/issues/33059#event-36731064748
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/33059
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/33059
P4A relatively minor issue that is not relevant to core functionshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22P4%22
area: elementsIssues related to Angular Elementshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20elements%22
area: performanceIssues related to performancehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20performance%22
state: confirmedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20confirmed%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.