Skip to content

fix(material/slider): prevent out of memory errors from tick marks on… - #34037

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/slider-tick-marks-ssr
Open

SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:fix/slider-tick-marks-ssr

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

The slider only renders its tick marks once it has a width, but it was computing them regardless, allocating one array entry per tick mark. Since the number of entries is derived from the min, max, step and value, a large range or a small step could result in an array big enough to exhaust the heap. This was especially problematic during server-side rendering, because the slider never has a width on the server so the array was always built and then discarded. If any of those inputs are derived from user input (e.g. query parameters), a single request could crash the server process along with every other request it was handling.

These changes skip computing the tick marks until the slider has a width.

Fixes #34036

… the server

The slider only renders its tick marks once it has a width, but it was computing them regardless, allocating one array entry per tick mark. Since the number of entries is derived from the `min`, `max`, `step` and value, a large range or a small step could result in an array big enough to exhaust the heap. This was especially problematic during server-side rendering, because the slider never has a width on the server so the array was always built and then discarded. If any of those inputs are derived from user input (e.g. query parameters), a single request could crash the server process along with every other request it was handling.

These changes skip computing the tick marks until the slider has a width.

Fixes angular#34036.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(MatSlider): showTickMarks can exhaust memory during SSR

1 participant