Title: @angular/ssr: getPrerenderParams silently skipped due to stateful /g regex in URL_PARAMETER_REGEXP · Issue #33154 · angular/angular-cli · GitHub
Open Graph Title: @angular/ssr: getPrerenderParams silently skipped due to stateful /g regex in URL_PARAMETER_REGEXP · Issue #33154 · angular/angular-cli
X Title: @angular/ssr: getPrerenderParams silently skipped due to stateful /g regex in URL_PARAMETER_REGEXP · Issue #33154 · angular/angular-cli
Description: Which @angular/* package(s) are the source of the bug? @angular/ssr Is this a regression? No Description When multiple parameterized routes use RenderMode.Prerender with getPrerenderParams, some routes are silently skipped — getPrerender...
Open Graph Description: Which @angular/* package(s) are the source of the bug? @angular/ssr Is this a regression? No Description When multiple parameterized routes use RenderMode.Prerender with getPrerenderParams, some ro...
X Description: Which @angular/* package(s) are the source of the bug? @angular/ssr Is this a regression? No Description When multiple parameterized routes use RenderMode.Prerender with getPrerenderParams, some ro...
Opengraph URL: https://github.com/angular/angular-cli/issues/33154
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@angular/ssr: getPrerenderParams silently skipped due to stateful /g regex in URL_PARAMETER_REGEXP","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\n@angular/ssr\n\n### Is this a regression?\n\nNo\n\n### Description\n\nWhen multiple parameterized routes use `RenderMode.Prerender` with `getPrerenderParams`, some routes are silently skipped — `getPrerenderParams` is never called, no prerendered HTML is produced, and no warning is emitted. The build reports \"Prerendered N static routes\" with N lower than expected.\n\n### Root cause\n\nIn `@angular/ssr/fesm2022/ssr.mjs`, function `handleSSGRoute`:\n\n```js\nconst URL_PARAMETER_REGEXP = /(?\u003c!\\\\):([^/]+)/g; // \u003c-- /g flag\n\nif (isCatchAllRoute && !getPrerenderParams ||\n !isCatchAllRoute && !URL_PARAMETER_REGEXP.test(currentRoutePath)) {\n yield { ...meta }; // early return, getPrerenderParams never called\n return;\n}\n```\n\nThe `/g` flag makes `RegExp.prototype.test()` stateful — `lastIndex` persists across calls. After a successful match, the next `.test()` call starts mid-string and may return `false` for a path that *does* contain a parameter. The route is then treated as static and yielded without invoking `getPrerenderParams`.\n\n### Standalone reproduction (no Angular needed)\n\n```js\nconst URL_PARAMETER_REGEXP = /(?\u003c!\\\\):([^/]+)/g;\nconsole.log(URL_PARAMETER_REGEXP.test('blog/:slug')); // true\nconsole.log(URL_PARAMETER_REGEXP.test('blog/kategorie/:cat')); // false ← BUG\n```\n\n### Suggested fix\n\nDrop the `/g` flag (not needed for `.test()`), or reset `lastIndex` before each test:\n\n```diff\n const isCatchAllRoute = CATCH_ALL_REGEXP.test(currentRoutePath);\n+ URL_PARAMETER_REGEXP.lastIndex = 0;\n if (isCatchAllRoute && !getPrerenderParams || !isCatchAllRoute && !URL_PARAMETER_REGEXP.test(currentRoutePath)) {\n```\n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n```true\nNo exception. The bug is silent: getPrerenderParams is not invoked for affected routes, and the build log reports a lower count of prerendered routes than expected without any warning.\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular : 21.2.4\nNode.js : 22.14.0\nPackage Manager : pnpm 10.6.5\nOperating System : win32 x64\n\nPackage Installed Version Requested Version\n@angular/build 21.2.2 ^21.2.2\n@angular/cdk 21.2.2 ^21.2.2\n@angular/cli 21.2.2 ^21.2.2\n@angular/common 21.2.4 ^21.2.0\n@angular/compiler 21.2.4 ^21.2.0\n@angular/compiler-cli 21.2.4 ^21.2.0\n@angular/core 21.2.4 ^21.2.0\n@angular/forms 21.2.4 ^21.2.0\n@angular/material 21.2.2 ^21.2.2\n@angular/platform-browser 21.2.4 ^21.2.0\n@angular/platform-server 21.2.4 ^21.2.0\n@angular/router 21.2.4 ^21.2.0\n@angular/ssr 21.2.2 ^21.2.2\nrxjs 7.8.2 ~7.8.0\ntypescript 5.9.3 ~5.9.2\n```\n\n### Anything else?\n\nAlso reproduced with `@angular/ssr` 21.2.10 and 22.0.0-next.7 by patching the file in `node_modules` and rerunning the build — the same routes are skipped without the `lastIndex = 0` fix.\n\nCurrently working around this via `pnpm patch`:\n\n```diff\n const isCatchAllRoute = CATCH_ALL_REGEXP.test(currentRoutePath);\n+ URL_PARAMETER_REGEXP.lastIndex = 0;\n if (isCatchAllRoute && !getPrerenderParams || !isCatchAllRoute && !URL_PARAMETER_REGEXP.test(currentRoutePath)) {\n```\n\nBefore patch: 7 of 11 expected parameterized routes were prerendered.\nAfter patch: all 20 routes correctly prerendered.\n\nHappy to submit a PR if helpful.","author":{"url":"https://github.com/SvenBudak","@type":"Person","name":"SvenBudak"},"datePublished":"2026-05-09T03:26:41Z","url":"https://github.com/angular/angular-cli/issues/33154"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0d66d24c-7c06-7b76-0fea-4108949b84cf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C29E:68C46:4902D5:64AB23:6AFDE5AC |
| html-safe-nonce | 07b02d7fb771d828bc15f44da67c68e633b3a2e634505d0199e3db77cabe5327 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjlFOjY4QzQ2OjQ5MDJENTo2NEFCMjM6NkFGREU1QUMiLCJ2aXNpdG9yX2lkIjoiNTYwNjc3MDU3NzY2NzY0Njg5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bb93887583d9b7f8ccdc324bb606eb5e5d4241557b10a8cfeaf60edb0f59fcf5 |
| hovercard-subject-tag | issue:4411978365 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/33154/issue_layout |
| twitter:image | https://opengraph.githubassets.com/48a289b762d5e6efef123a6f69c7971a15728468bffb7817d06095befd1b3fff/angular/angular-cli/issues/33154 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/48a289b762d5e6efef123a6f69c7971a15728468bffb7817d06095befd1b3fff/angular/angular-cli/issues/33154 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? @angular/ssr Is this a regression? No Description When multiple parameterized routes use RenderMode.Prerender with getPrerenderParams, some ro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SvenBudak |
| hostname | github.com |
| expected-hostname | github.com |
| None | 91ef1a291a064ac31ac459ab3f75261dbdd924c41ea5bd027e591c5b46cc9ce7 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d62bc98ce2346f4006e4a2810e9e22f37e7e6422 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width