Visitar URL original
Hostbinding fails when there are several thousand context matches · Issue #37876 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20220322094228/https://github.com/angular/angular/issues/37876
Skip to content
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

Hostbinding fails when there are several thousand context matches #37876

Closed
langfors opened this issue Jul 1, 2020 · 2 comments
Closed

Hostbinding fails when there are several thousand context matches #37876

langfors opened this issue Jul 1, 2020 · 2 comments

Comments

@langfors
Copy link

@langfors langfors commented Jul 1, 2020

🐞 bug report

Affected Package

The issue is caused by package @angular/router

Is this a regression?

Yes, the previous version in which this bug was not present was: 8.2.14

Description

On a page with a large number of [routerLink] directives the following Error is thrown. The number of router links appears to be somewhere > 3000.

🔬 Minimal Reproduction

https://stackblitz.com/...

A repro repo can be found here: https://github.com/langfors/manyRouterlinks

🔥 Exception or Error




core.js:6228 ERROR TypeError: Cannot read property 'href' of undefined
    at RouterLinkWithHref_HostBindings (router.js:8437)
    at setHostBindingsByExecutingExpandoInstructions (core.js:11665)
    at refreshView (core.js:12046)
    at refreshComponent (core.js:13445)
    at refreshChildComponents (core.js:11716)
    at refreshView (core.js:12051)
    at refreshEmbeddedViews (core.js:13391)
    at refreshView (core.js:12022)
    at refreshComponent (core.js:13445)
    at refreshChildComponents (core.js:11716)

🌍 Your Environment

Angular Version:





9.1.11

Anything else relevant?

@ngbot ngbot bot added this to the needsTriage milestone Jul 1, 2020
@atscott atscott changed the title "ERROR TypeError: Cannot read property 'href' of undefined" on a page with many routerLinks Hostbinding fails when there are several thousand context matches Jul 6, 2020
@atscott
Copy link
Contributor

@atscott atscott commented Jul 6, 2020

reproduction without the router: https://github.com/atscott/manyhostbindings (note that I created my own routerLink with just the @HostBinding)

crisbeto added a commit to crisbeto/angular that referenced this issue Jul 11, 2020
… bindings

We currently use 16 bits to store information about nodes in a view. The 16 bits give us 65536 entries in the array, but the problem is that while the number is large, it can be reached by ~4300 directive instances with host bindings which could realistically happen is a very large view, as seen in angular#37876. Once we hit the limit, we end up overflowing which eventually leads to a runtime error.

These changes bump to using 20 bits which gives us around 1048576 entries in the array or 16 times more than the current amount which could still technically be reached, but is much less likely and the user may start hitting browser limitations by that point.

I picked the 20 bit number since it gives us enough buffer over the 16 bit one, while not being as massive as a 24 bit or 32 bit.

I've also added a dev mode assertion so it's easier to track down if it happens again in the future.

Fixes angular#37876.
crisbeto added a commit to crisbeto/angular that referenced this issue Jul 11, 2020
… bindings

We currently use 16 bits to store information about nodes in a view.
The 16 bits give us 65536 entries in the array, but the problem is that while
the number is large, it can be reached by ~4300 directive instances with host
bindings which could realistically happen is a very large view, as seen in angular#37876.
Once we hit the limit, we end up overflowing which eventually leads to a runtime error.

These changes bump to using 20 bits which gives us around 1048576 entries in
the array or 16 times more than the current amount which could still technically
be reached, but is much less likely and the user may start hitting browser limitations
by that point.

I picked the 20 bit number since it gives us enough buffer over the 16 bit one,
while not being as massive as a 24 bit or 32 bit.

I've also added a dev mode assertion so it's easier to track down if it happens
again in the future.

Fixes angular#37876.
@crisbeto crisbeto self-assigned this Jul 11, 2020
AndrewKushnir added a commit that referenced this issue Jul 17, 2020
… bindings (#38014)

We currently use 16 bits to store information about nodes in a view.
The 16 bits give us 65536 entries in the array, but the problem is that while
the number is large, it can be reached by ~4300 directive instances with host
bindings which could realistically happen is a very large view, as seen in #37876.
Once we hit the limit, we end up overflowing which eventually leads to a runtime error.

These changes bump to using 20 bits which gives us around 1048576 entries in
the array or 16 times more than the current amount which could still technically
be reached, but is much less likely and the user may start hitting browser limitations
by that point.

I picked the 20 bit number since it gives us enough buffer over the 16 bit one,
while not being as massive as a 24 bit or 32 bit.

I've also added a dev mode assertion so it's easier to track down if it happens
again in the future.

Fixes #37876.

PR Close #38014
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Aug 17, 2020

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 Aug 17, 2020
profanis added a commit to profanis/angular that referenced this issue Sep 5, 2020
… bindings (angular#38014)

We currently use 16 bits to store information about nodes in a view.
The 16 bits give us 65536 entries in the array, but the problem is that while
the number is large, it can be reached by ~4300 directive instances with host
bindings which could realistically happen is a very large view, as seen in angular#37876.
Once we hit the limit, we end up overflowing which eventually leads to a runtime error.

These changes bump to using 20 bits which gives us around 1048576 entries in
the array or 16 times more than the current amount which could still technically
be reached, but is much less likely and the user may start hitting browser limitations
by that point.

I picked the 20 bit number since it gives us enough buffer over the 16 bit one,
while not being as massive as a 24 bit or 32 bit.

I've also added a dev mode assertion so it's easier to track down if it happens
again in the future.

Fixes angular#37876.

PR Close angular#38014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants