fix(http): Only contribute to ApplicationRef.isStable
indicator in …
#55075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…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 thePendingTasks
service to contribute to application stability. This was added in v16 to support SSR without relying on an infinitesetTimeout
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. (28c68f7)=== Additional background information ===
Prior to #54949,
PendingTasks
contribute toApplicationRef.isStable
but did not contribute to the stability ofComponentFixture
. 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 withHttpClient
. Tests appear to quite often useawait 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 thePendingTasks
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 beforeawait fixture.whenStable
.BREAKING CHANGE:
HttpClient
interceptors are no longer contribute directly toApplicationRef.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.