Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
Angular Router stores matrix parameters in regular JavaScript objects.
Numeric parameter names such as:
behave very differently in V8 compared with normal string keys.
For example, these two paths have the same length and contain the same number of matrix parameters:
but the numeric version uses significantly more memory.
During Angular SSR, this difference becomes large enough that a relatively small burst of concurrent requests can exhaust the Node.js heap.
I tested this through Nginx using request sizes that still fit within its normal 8 KiB request-line limit:
| V8 old space |
Concurrent requests |
Segments/request |
Request path size |
| 256 MiB |
12 |
742 |
8,162 B |
| 512 MiB |
22 |
742 |
8,162 B |
With a 256 MiB heap, 12 concurrent requests using the numeric version consistently terminate the SSR worker with:
JavaScript heap out of memory
The same-size control using normal string keys completes successfully and Angular remains healthy.
The reproduction briefly keeps requests active for 500 ms so that their SSR work overlaps consistently. This is only to make the memory difference easy to reproduce.
Please provide a link to a minimal reproduction of the bug
https://github.com/SkyZeroZx/angular-router-ssr-oom-lab
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
Angular Router stores matrix parameters in regular JavaScript objects.
Numeric parameter names such as:
behave very differently in V8 compared with normal string keys.
For example, these two paths have the same length and contain the same number of matrix parameters:
but the numeric version uses significantly more memory.
During Angular SSR, this difference becomes large enough that a relatively small burst of concurrent requests can exhaust the Node.js heap.
I tested this through Nginx using request sizes that still fit within its normal 8 KiB request-line limit:
With a 256 MiB heap, 12 concurrent requests using the numeric version consistently terminate the SSR worker with:
The same-size control using normal string keys completes successfully and Angular remains healthy.
The reproduction briefly keeps requests active for 500 ms so that their SSR work overlaps consistently. This is only to make the memory difference easy to reproduce.
Please provide a link to a minimal reproduction of the bug
https://github.com/SkyZeroZx/angular-router-ssr-oom-lab