question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HttpClient pushes undefined down the observable stream on error

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
steeefyyycommented, May 17, 2018

hello, how did you fix it @abdullahsari ? got the same, probably my http_interceptor as well 😕

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found