Skip to content

Angular Router numeric matrix parameters can exhaust memory during SSR #70716

Description

@SkyZeroZx

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:

/a;990;2522

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:

/a;990;2522
/a;aaa;bbbb

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routergemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions