forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(http): Only contribute to
ApplicationRef.isStable
indicator in …
…the `HttpBackend` This commit updates the approach to how the `http` package contributes to application stability by moving the contribution point from an interceptor wrapper to the backend. `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. (angular@28c68f7) === Additional background information === Prior to angular#54949, `PendingTasks` contribute to `ApplicationRef.isStable` but did not contribute to the stability of `ComponentFixture`. This divergence in stability behavior was not intended. By aligning the two behaviors again, this includes all pending tasks in the stability of fixtures. This is likely to be a pretty large breaking change test with `HttpClient`. 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` in tests by not including the stability contribution in the mock backend. In this scenario, requests need to be flushed manually for them to resolve, which is problematic for existing test suites which do not flush them before `await fixture.whenStable`. BREAKING CHANGE: `HttpClient` interceptors are no longer contribute directly to `ApplicationRef.isStable` without ZoneJS. `ApplicationRef.isStable` is used for SSR to determine when to serialize the application. If there is async work in interceptors that is not captured by ZoneJS and needs to be included in the SSR serialization, these should be updated to keep the zone unstable by running a timeout inside the zone and clearing it when the async interceptor work is finished.
- Loading branch information
Showing
9 changed files
with
259 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.