Skip to content

fix: avoid sparse storage for numeric attribute names - #49

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix-numeric-attr
Open

SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix-numeric-attr

Conversation

@SkyZeroZx

Copy link
Copy Markdown

Store qualified attribute names in a Map so V8 does not treat numeric names such as 2539 as array indexes. Reconstructing formatting elements with these properties could otherwise allocate large sparse backing stores and exhaust an Angular SSR worker's heap.

Keep numeric names available through the standard attribute APIs while reserving NamedNodeMap numeric properties for attribute positions. Add regression coverage for parsing, mutation, cloning, namespaces, formatting reconstruction, and incremental parsing.

Fixes angular/angular#70826

More context: https://issuetracker.google.com/issues/559856174

Store qualified attribute names in a Map so V8 does not treat names such as `2539` as array indexes. Reconstructing formatting elements with those indexed properties could otherwise exhaust an Angular SSR worker's heap.

Keep numeric names available through the standard attribute APIs, but do not mirror them onto NamedNodeMap because its numeric properties represent attribute positions.

Add regression tests for parsing, mutation, cloning, and formatting reconstruction.

Fixes angular/angular#70826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular SSR can exhaust memory while sanitizing numeric HTML attribute names

1 participant