I'm writing a react application using Router1. Here is how the final subscription looks like:
router
.renderResult()
.forEach(() => {
window.ga('send', 'pageview', window.location.pathname);
});
This stream throwing an error (unhandled error), but I don't see it in the console. If I put onError callback in forEach
- I can log errors.
If I fix error in stream and create another stream inside, that throws an error, I don't see the message in console:
router
.renderResult()
.forEach(() => {
window.ga('send', 'pageview', window.location.pathname);
Observable.throw(1).subscribe();
});
And even if I replace Observable.throw(1).subscribe();
with simple throw 1
- result is the same, no messages in console and stream is broken.
But If I fix error in the stream, and create another stream that throws an error after some timeout, I see the message "rx.all.js:77 Uncaught 1" which is great.
router
.renderResult()
.forEach(() => {
window.ga('send', 'pageview', window.location.pathname);
setTimeout(() => Observable.throw(1).subscribe(), 1000);
});
So by default rx throws unhandled exceptions, but not in this case, why? Who eating my errors? Any ideas how can I debug it?
So I've found who was eating my tasty errors - [email protected]. Issue is already fixed and will be released in the next version.
Here is example how you can feed errors to superagent:
import { Observable } from 'rx';
import superagent from 'superagent';
const request = superagent.get('/');
Observable.defer(
Observable.fromNodeCallback(request.end, request, res => res.body)
).subscribe(() => {
throw new Error('tasty error');
});