gilsdav / ngx-translate-router

Translate routes using ngx-translate
132 stars 43 forks source link

SSR maximum call stack size exceeded #111

Closed devhus closed 3 years ago

devhus commented 3 years ago

using Angular universal for SSR is causing maximum call stack size exceeded error. download the sample project, after installing packages run npm run dev:ssr command then reload the home page twice on the live server URL(default: http://localhost:4200).

RangeError: Maximum call stack size exceeded
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90573:18)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)
    at deepCopy (C:\xampp\htdocs\bnaturalia\bnaturalia-frontend-2\dist\bnaturlia-frontend\server\main.js:90578:58)

bnaturalia-frontend-2.zip

devhus commented 3 years ago

After a bit of research, the issue is caused by a recursive function this lib has, which repeatedly calls itself until the call stack size runs out.

https://github.com/gilsdav/ngx-translate-router/blob/86d2e52f62d61d59d3b5d4c954f4a10f84ffda59/projects/ngx-translate-router/src/lib/util.ts#L71

juanmaldonadodev commented 1 year ago

@devhus How did you fix this?