HttpClient pushes undefined down the observable stream on error
See original GitHub issueI’m submitting a…
[X] Regression (a behavior that used to work and stopped working in a new release)
[] Bug report
[] Feature request
[] Documentation issue or request
[] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
An error instance does not exist when the backend responds with an error (can be a general issue, I only experienced it with the post and put method so far)
TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at subscribeToResult (subscribeToResult.js:74)
at CatchSubscriber.error (catchError.js:112)
at XMLHttpRequest.onLoad (http.js:2283)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4740)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at ZoneTask.invokeTask [as invoke] (zone.js:496)
at invokeTask (zone.js:1517)
at XMLHttpRequest.globalZoneAwareCallback (zone.js:1543)
Expected behavior
HttpClient should give the error instance instead of undefined
Minimal reproduction of the problem with instructions
- Call a backend API with HttpClient.post/HttpClient.put and make sure the call will result in an error
- Use either the catchError operator or catch the error in the observer
- Try logging the error instance to the console
- You will probably get a similar stracktrace from above
What is the motivation / use case for changing the behavior?
Well, it’s quite obvious no need to mention anything.
Environment
Angular version: 5.2.7
Browser:
- [X] Chrome (desktop) version 64.0.3282.186 (Official build) (64-bits) (cohort: Stable)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: 8.9.1
- Platform: Windows
Others:
RxJS version 5.5.6
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
You provided 'undefined' where a stream was expected ...
I faced this issue when creating a new project using generator-jhipster-ionic (yo jhipster-ionic giving v3.1.2), following Matt Raible's ...
Read more >Angular 9 HTTP Post request Error. You provided 'undefined ...
Hi, I have been setting up a app.service file for various API calls to a backend system. I recently upgraded the platform from...
Read more >Communicating with backend services using HTTP - Angular
The HttpClient.get() method normally returns an observable that emits a single value, either the data or an error. An interceptor can change this...
Read more >tap - RxJS
The observable returned by tap is an exact mirror of the source, with one exception: Any error that occurs -- synchronously -- in...
Read more >Angular Observable Data Services - Cory Rylan
Now anytime we call one of these methods any component subscribed to our public todos Observable stream will get a value pushed down...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hello, how did you fix it @abdullahsari ? got the same, probably my http_interceptor as well 😕
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.