-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(common): incorrect error type for XHR errors in TestRequest
#36082
fix(common): incorrect error type for XHR errors in TestRequest
#36082
Conversation
98ec624
to
7ecec02
Compare
cd1d50f
to
6c52c2f
Compare
6c52c2f
to
5acd0f2
Compare
5acd0f2
to
58698c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
…gular#36082) 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. PR Close angular#36082
Currently the
HttpClient
always 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
TestRequest
class provided by@angular/common/http/testing
where errors are considered beingof type
ErrorEvent
. This is incorrect becauseErrorEvent
s provideinformation for errors in scripts or files which are evaluated. Since
the
HttpClient
never evaluates scripts/files, and also since XHR requestsclearly are documented to emit
ProgressEvent
's, we should change theTestSupport
to retrieve suchProgressEvent
's instead of incompatibleobjects of type
ErrorEvent
.Resources:
Related to: #34748.