fix(common): incorrect error type for XHR errors in TestRequest#36082
fix(common): incorrect error type for XHR errors in TestRequest#36082devversion wants to merge 1 commit intoangular:masterfrom
TestRequest#36082Conversation
98ec624 to
7ecec02
Compare
cd1d50f to
6c52c2f
Compare
6c52c2f to
5acd0f2
Compare
5acd0f2 to
58698c6
Compare
jelbourn
left a comment
There was a problem hiding this comment.
LGTM - does anything need to go into the deprecation doc?
Reviewed-for: public-api
bffca6e to
3cac51b
Compare
This comment has been minimized.
This comment has been minimized.
|
You can preview 3e29972 at https://pr36082-3e29972.ngbuilds.io/. |
|
@jessicajaniuk I've just resurrected this PR. Addressed feedback etc. I just need one more public API approval. |
jessicajaniuk
left a comment
There was a problem hiding this comment.
LGTM 🍪
reviewed-for: public-api
|
I'll run a TGP to make sure we're safe in google3 with this change. |
Currently the `HttpClient` always wraps errors from XHR requests, but the underlying errors are always of type `ProgressEvent`, or don't have a native error if the status code is just indicating failure (e.g. 404). This behavior does not match in the `TestRequest` class provided by `@angular/common/http/testing` where errors are considered being of type `ErrorEvent`. This is incorrect because `ErrorEvent`s provide information for errors in scripts or files which are evaluated. Since the `HttpClient` never evaluates scripts/files, and also since XHR requests clearly are documented to emit `ProgressEvent`'s, we should change the `TestSupport` to retrieve such `ProgressEvent`'s instead of incompatible objects of type `ErrorEvent`. In favor of having a deprecation period, we keep supporting `ErrorEvent` in the `TestRequest.error` signature. Eventually, we can remove this signature in the future. Resources: * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/error_event * https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent * https://xhr.spec.whatwg.org/#event-xhr-errpr Related to: angular#34748. DEPRECATED: `TestRequest` from `@angular/common/http/testing` no longer accepts `ErrorEvent` when simulating XHR errors. Instead instances of `ProgressEvent` should be passed, matching with the native browser behavior.
3e29972 to
9598e7c
Compare
|
@devversion Can you rebase this and repush? It seems to fail to build in google3 now. |
|
You can preview 9598e7c at https://pr36082-9598e7c.ngbuilds.io/. |
|
The TGP passed. |
|
This PR was merged into the repository by commit 489cf42. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently the
HttpClientalways wraps errors from XHR requests, butthe underlying errors are always of type
ProgressEvent, or don't havea native error if the status code is just indicating failure (e.g. 404).
This behavior does not match in the
TestRequestclass provided by@angular/common/http/testingwhere errors are considered beingof type
ErrorEvent. This is incorrect becauseErrorEvents provideinformation for errors in scripts or files which are evaluated. Since
the
HttpClientnever evaluates scripts/files, and also since XHR requestsclearly are documented to emit
ProgressEvent's, we should change theTestSupportto retrieve suchProgressEvent's instead of incompatibleobjects of type
ErrorEvent.Resources:
Related to: #34748.