Title: Incremental hydration drops an event caught inside a block whose viewport hydration already started · Issue #72006 · angular/angular · GitHub
Open Graph Title: Incremental hydration drops an event caught inside a block whose viewport hydration already started · Issue #72006 · angular/angular
X Title: Incremental hydration drops an event caught inside a block whose viewport hydration already started · Issue #72006 · angular/angular
Description: Which @angular/ package(s) are the source of the bug?* core Is this a regression? No Description With withIncrementalHydration() and @defer (hydrate on viewport), a click or keydown on an element inside the block is lost when it arrives ...
Open Graph Description: Which @angular/ package(s) are the source of the bug?* core Is this a regression? No Description With withIncrementalHydration() and @defer (hydrate on viewport), a click or keydown on an element i...
X Description: Which @angular/ package(s) are the source of the bug?* core Is this a regression? No Description With withIncrementalHydration() and @defer (hydrate on viewport), a click or keydown on an element i...
Opengraph URL: https://github.com/angular/angular/issues/72006
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incremental hydration drops an event caught inside a block whose viewport hydration already started","articleBody":"**Which @angular/* package(s) are the source of the bug?** core\n\n**Is this a regression?** No\n\n**Description**\n\nWith `withIncrementalHydration()` and `@defer (hydrate on viewport)`, a click or keydown on an element inside the block is lost when it arrives after the viewport trigger started hydrating the block but before hydration finished.\n\n`hydrateAndInvokeBlockListeners` (`packages/core/src/hydration/event_replay.ts`) queues the event and calls `triggerHydrationFromBlockName(injector, blockName, replayFn)`. Because the viewport trigger already put the block in `dehydratedBlockRegistry.hydrating`, `triggerHydrationFromBlockName` (`packages/core/src/defer/triggering.ts`) returns at:\n\n```ts\nif (blocksBeingHydrated.has(blockName)) {\n return;\n}\n```\n\nThe in-flight hydration was started by the viewport trigger with no `replayQueuedEventsFn`, so nothing replays the queue when it finishes. The event stays in `EVENT_REPLAY_QUEUE` until some later event-triggered hydration happens to flush it, or forever.\n\nPresent in 22.2.6 and on `main`.\n\n**Reproduction** (seen in a production app; these steps are the reduced shape, not yet a standalone StackBlitz)\n\n1. SSR app with `provideClientHydration(withIncrementalHydration())`.\n2. `@defer (hydrate on viewport) { \u003cbutton (click)=\"count = count + 1\">{{ count }}\u003c/button> }` below the fold, with a lazily loaded dependency so hydration takes a few hundred ms (throttle the network).\n3. Scroll the block into view and click the button immediately, before hydration finishes.\n\nExpected: the click is replayed after hydration and `count` becomes 1. Actual: `count` stays 0.\n\n**Proposed fix**\n\nWhen the block is already hydrating, replay the queued events once that hydration settles:\n\n```ts\nconst hydrating = blocksBeingHydrated.get(blockName);\nif (hydrating) {\n if (replayQueuedEventsFn) {\n hydrating.promise.then(() => replayQueuedEventsFn([blockName]), () => {});\n }\n return;\n}\n```\n\n`createReplayQueuedBlockEventsFn` already requeues events for blocks not in the list, so passing `[blockName]` replays only this block's events.\n\n","author":{"url":"https://github.com/Haembina","@type":"Person","name":"Haembina"},"datePublished":"2026-11-12T13:15:42Z","url":"https://github.com/angular/angular/issues/72006"}
| 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:ca361d62-a966-5dcb-fba7-8ee337775c67 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DB2:29AEE8:2E2876B:3D836ED:6B01D668 |
| html-safe-nonce | 02eafbd9411bee2bc6e3d4e0ac4b6d59940c06ee2bc6927ed0599e67f4966532 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REIyOjI5QUVFODoyRTI4NzZCOjNEODM2RUQ6NkIwMUQ2NjgiLCJ2aXNpdG9yX2lkIjoiNTg1MDQzMTcxMzExNjgwNDcxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3de0dcbc2235b50b10c058252f3af26187de94cf23ae66f03f14ca99e70c4e54 |
| hovercard-subject-tag | issue:6350607221 |
| 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/72006/issue_layout |
| twitter:image | https://opengraph.githubassets.com/789870d4d837d4b723231a7e6a341b3f1387bb66619a9f3b917fb256f10437cf/angular/angular/issues/72006 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/789870d4d837d4b723231a7e6a341b3f1387bb66619a9f3b917fb256f10437cf/angular/angular/issues/72006 |
| og:image:alt | Which @angular/ package(s) are the source of the bug?* core Is this a regression? No Description With withIncrementalHydration() and @defer (hydrate on viewport), a click or keydown on an element i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Haembina |
| 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