mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
6993146a25
`HttpClient` uses the `PendingTasks` service to contribute to application stability. This was added in v16 to support SSR without relying on an infinite `setTimeout` with ZoneJS like it did pre-v16. Prior to version 16, this was also only done on the server and did not affect clients or unit tests (https://github.com/angular/angular/commit/28c68f709cdc930e12bac51a266e7bf790656034). Today, `PendingTasks` contribute to `ApplicationRef.isStable` but do not contribute to the stability of `ComponentFixture`. This divergence in stability behavior was not intended and we plan to make these two stability indicators the same again, like they were when it was solely based on the state of the Zone. By aligning the two behaviors again, this would include all pending tasks in the stability of fixtures. After investigation, this seems likely to be a pretty large breaking change. Tests appear to quite often use `await fixture.whenStable` when there are unfinished requests that have not been mocked or flushed. This change prevents request in `HttpClient` from contributing to stability through the `PendingTasks` automatically but only when using `HttpClientTesting`. In this scenario, requests need to be expected and flushed manually for them to resolve. When the test backend and controllers aren't used, requests should resolve on their own so `await fixture.whenStable` shouldn't be particularly affected or problematic. PR Close #54974