Title: core: hydration retains the first routed SSR DOM through segmentHeads after navigation · Issue #72010 · angular/angular · GitHub
Open Graph Title: core: hydration retains the first routed SSR DOM through segmentHeads after navigation · Issue #72010 · angular/angular
X Title: core: hydration retains the first routed SSR DOM through segmentHeads after navigation · Issue #72010 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description In Angular 22.2.6, the DOM of the initially server-rendered routed component remains in memory after navigating away from that route. The c...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description In Angular 22.2.6, the DOM of the initially server-rendered routed component remains in memory afte...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description In Angular 22.2.6, the DOM of the initially server-rendered routed component remains in memory afte...
Opengraph URL: https://github.com/angular/angular/issues/72010
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"core: hydration retains the first routed SSR DOM through segmentHeads after navigation","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncore\n\n### Is this a regression?\n\nYes\n\n### Description\n\nIn Angular 22.2.6, the DOM of the initially server-rendered routed component remains in memory after navigating away from that route.\n\nThe component’s `ngOnDestroy()` runs and its host is disconnected from the document, but the root view’s hydration data still holds a strong reference to it:\n\nRoot component LView → LView[HYDRATION] → segmentHeads[0] → detached initial route component host → its DOM subtree\n\nForced garbage collection does not release the subtree.\n\n### Reproduction\n\nI reproduced this in a minimal application with:\n\n- A root component containing only `\u003crouter-outlet />`.\n- Route `/`, rendering a component with 1,000 paragraphs.\n- Route `/b`, rendering another component with one paragraph.\n- SSR and `provideClientHydration()`.\n\nThere are no third-party widgets, application services, template event listeners, i18n blocks, `@defer` blocks, or custom route reuse strategy.\n\nBefore bootstrap, I stored only a `WeakRef` to the original SSR component host. After bootstrap, I verified that hydration reused that exact node.\n\nI then navigated to `/b`, waited for application stability and browser tasks, and forced garbage collection through CDP’s `HeapProfiler.collectGarbage`. I repeated this across four navigation cycles.\n\n### Actual behavior\n\n| Configuration | Original SSR host retained after navigation and GC |\n|---|---|\n| `provideClientHydration()` | Yes, all four cycles |\n| `provideClientHydration(withNoIncrementalHydration())` | Yes, all four cycles |\n| No hydration providers | No; the original SSR DOM is replaced at bootstrap |\n\nIn both hydrated configurations:\n\n- `ngOnDestroy()` runs.\n- The original host has `isConnected === false`.\n- `segmentHeads` still references the original host.\n- The original host survives forced garbage collection.\n\nSubsequent client-created instances were collected in the recorded run. This appears to be bounded retention of the initial SSR subtree rather than an unbounded leak on every navigation.\n\nThe no-hydration case is a control: the original SSR DOM is replaced during bootstrap, so it is not a like-for-like measurement of the later client-created DOM.\n\n### Expected behavior\n\nOnce the initially hydrated routed component has been destroyed, obsolete hydration bookkeeping in a surviving ancestor view should not prevent its DOM from being garbage-collected.\n\n### Investigation\n\nIn the installed Angular 22.2.6 code, `setSegmentHead()` stores strong DOM references.\n\nThe inspected cleanup path clears i18n hydration data and traverses child views and containers, but leaves `segmentHeads` in place.\n\nAny cleanup fix would need to preserve metadata still required by pending incremental hydration.\n\nThe diagnostic code only reads Angular internals; it does not modify them. DOM nodes were not logged, returned as DevTools handles, or retained through element selection. No performance traces were recorded.\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\n\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular packages: 22.2.6 (core, common, compiler, platform-browser, platform-server, router)\nNode.js: 24.22.1\nOS / arch: macOS / arm64\nChrome: 157.0.8103.51 (headless)\nPlaywright: 1.62.1\nesbuild: 0.28.2\nRxJS: 7.8.2\nChange detection: zoneless\nRendering: SSR followed by client hydration\nCompilation: JIT, enableProdMode(), browser ngDevMode=false\n\n\nThis standalone harness does not use the Angular CLI or an AOT production build.\nThe same retention path was originally observed in an application production\nbuild; the attached evidence is from the isolated JIT reproduction above.\n```\n\n### Anything else?\n\n[Event replay issue #66506](https://github.com/angular/angular/issues/66506)\ndescribes a different retention path. This report remains reproducible with\nincremental hydration disabled and with no event listeners, so disabling event\nreplay does not resolve the observed `segmentHeads` retention.","author":{"url":"https://github.com/Rambuto","@type":"Person","name":"Rambuto"},"datePublished":"2026-11-12T16:41:38Z","url":"https://github.com/angular/angular/issues/72010"}
| 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:272ddc08-36d9-4374-e24b-8755ff5feca3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C3A:19B6A2:FEA3E3:150F682:6B01DB9C |
| html-safe-nonce | 868a287a649abe6feff926c5ae4341684ac640862a4a80f585274d2f6d7c0fd7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzNBOjE5QjZBMjpGRUEzRTM6MTUwRjY4Mjo2QjAxREI5QyIsInZpc2l0b3JfaWQiOiI3NDY0NDc0NTI1OTYzNTA4NjM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ed228b935e3aca19c3b928fa78dfa259b13443f05dc0f95b20fc44f08f556a34 |
| hovercard-subject-tag | issue:6354520931 |
| 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/72010/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30da04f49df1fc89af2520fb7e4273cfc826cbd895191cdcea2853ad4f1ca072/angular/angular/issues/72010 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30da04f49df1fc89af2520fb7e4273cfc826cbd895191cdcea2853ad4f1ca072/angular/angular/issues/72010 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? Yes Description In Angular 22.2.6, the DOM of the initially server-rendered routed component remains in memory afte... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Rambuto |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width