Title: SSR dev-server HMR does not dispose hydrated layout, causing duplicated components after root template change · Issue #32256 · angular/angular-cli · GitHub
Open Graph Title: SSR dev-server HMR does not dispose hydrated layout, causing duplicated components after root template change · Issue #32256 · angular/angular-cli
X Title: SSR dev-server HMR does not dispose hydrated layout, causing duplicated components after root template change · Issue #32256 · angular/angular-cli
Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Summary In an SSR-enabled Angular project, when running ng ser...
Open Graph Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Summary In an SSR-enab...
X Description: Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Summary In an SSR-enab...
Opengraph URL: https://github.com/angular/angular-cli/issues/32256
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SSR dev-server HMR does not dispose hydrated layout, causing duplicated components after root template change","articleBody":"### Command\n\nserve\n\n### Is this a regression?\n\n- [ ] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n_No response_\n\n### Description\n\n### Summary\nIn an SSR-enabled Angular project, when running `ng serve`, editing the root component template (`src/app/app.html`) and then refreshing the browser results in duplicated layout DOM nodes. Header/footer appear twice.\n\nDevTools shows **two sibling `app-shell` elements under a single `app-root`** (the root is not duplicated; only the layout is duplicated). This does **not** reproduce in a non-SSR project.\n\n### Expected\nAfter saving template changes and refreshing, the hydrated SSR component tree should be disposed properly and the layout should render exactly once.\n\n### Actual\nAfter editing the root template and refreshing:\n- previous hydrated layout is not destroyed\n- a second `app-shell` is appended\n- header/footer are rendered twice\n- DOM order becomes inconsistent (router-outlet ends up between the two layouts)\n\n### Notes\nI have attached screenshots (DevTools Elements) showing `app-shell` duplicated the repro.\n\n### ng serve\n\u003cimg width=\"1904\" height=\"804\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/a5c471cb-8855-422d-920a-426788252ce9\" /\u003e\n\n### After change and save\n\u003cimg width=\"1883\" height=\"818\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/804cfa1f-e264-4e0d-b778-e0dc3eb548bd\" /\u003e\n\n### After refresh page\n\u003cimg width=\"1919\" height=\"848\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/0b22b643-c2fb-4d1e-a570-a7cff956df04\" /\u003e\n\n### Minimal Reproduction\n\n### Repro repo\n\nhttps://github.com/alikarimli/angular-ssr-hmr-duplication-repro.git\n\n### Steps\n1. `git clone https://github.com/alikarimli/angular-ssr-hmr-duplication-repro.git`\n2. `npm ci`\n3. `npx ng serve`\n4. Open the app in the browser.\n5. Edit `src/app/app.html` (add a comment or whitespace), save.\n6. Refresh the browser.\n7. Observe duplicated layout (header/footer). In DevTools, `app-shell` appears twice under a single `app-root`.\n\n### Important\n- This only reproduces with SSR enabled.\n- A non-SSR project does not reproduce the issue.\n\n\n### Exception or Error\n\n```text\nNo exception is thrown. No console errors observed.\n```\n\n### Your Environment\n\n```text\nAngular CLI: 20.3.7\nNode: 22.20.0\nPackage Manager: npm 11.6.2\nOS: win32 x64\n\nAngular: \u003cerror\u003e\n... build, common, compiler, compiler-cli, core, forms\n... platform-browser, platform-server, router, ssr\n\nPackage Version\n------------------------------------\n@angular-devkit/architect 0.2003.7 (cli-only)\n@angular-devkit/core 20.3.7 (cli-only)\n@angular-devkit/schematics 20.3.7 (cli-only)\n@angular/cli 20.3.7 (cli-only)\n@schematics/angular 20.3.14\nrxjs 7.8.2\ntypescript 5.9.3\nzone.js 0.15.1\n```\n\n### Anything else relevant?\n\n- Browser: Chrome (latest) on Windows 11\n- Happens only after editing the root template (`src/app/app.html`) while dev-server is running and then refreshing the page.\n- `app-root` is not duplicated; only `app-shell` is duplicated (see attached DevTools screenshots).\n- Workaround: `ng serve --no-hmr` prevents the issue (if applicable).\n","author":{"url":"https://github.com/alikarimli","@type":"Person","name":"alikarimli"},"datePublished":"2026-01-09T22:25:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/32256/angular-cli/issues/32256"}
| 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:1594b67a-8b1f-70c7-7d21-89fd139b1fff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B44:32B525:75D7CE:9CD733:696487A4 |
| html-safe-nonce | dcd904261a73a24dc24ab91095ae27de5ca58806fba364ec8350969e18af14aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjQ0OjMyQjUyNTo3NUQ3Q0U6OUNENzMzOjY5NjQ4N0E0IiwidmlzaXRvcl9pZCI6IjI3ODU2OTQ5NjM2NTczNzc3MDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e3df3a511f1212a161c7eb85e1b493bb5c3c3ec4ce666a983947984a54b66c88 |
| hovercard-subject-tag | issue:3798529487 |
| 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/32256/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0fdf21f566549f2b9b957510be4a1bbfa15d95ac9c903e52da910f7036260dba/angular/angular-cli/issues/32256 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0fdf21f566549f2b9b957510be4a1bbfa15d95ac9c903e52da910f7036260dba/angular/angular-cli/issues/32256 |
| og:image:alt | Command serve Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description Summary In an SSR-enab... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alikarimli |
| hostname | github.com |
| expected-hostname | github.com |
| None | baa7d9900fdf7b27d604f36887af878d569cfbdcf97126832a5f4f0caf0c6ba5 |
| 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 | 842eff1d11f899d02b6b3b98fa3ea4860e64b34e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width