Continue stream after error
See original GitHub issueI wonder if there is a way to handle single error in the stream and continue? The only way i found is to make concatMap + recoverWith + most.empty()
stream$
.concatMap(x => most.just(x)
.map(mayThrow)
.recoverWith(e => {
console.log('CAUGHT', e);
return most.empty();
})
)
.forEach(x => console.log('result', x));
Would be nice to have method like handleError
to do side effects and move on
Or maybe tapErrors
and filterErrors
similar to tap
and filter
Or even concatMapError
to replace each error with a stream
stream$
.map(mayThrow)
.tapErrors(e => console.log('CAUGHT', e))
.filterErrors(e => e.message !== 'Known error')
.forEach(x => console.log('result', x));
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Catch, Recover, and Continue RxJS Streams After An Error
RxJS automatically kills streams when errors occur. This is hard coded. The solution: use disposable streams.
Read more >How to catch error and continue executing a sequence in RxJs?
This does not seem to work in RxJS v6. I tried migrating the code and the observable completes after the error is caught....
Read more >Error handling with reactive streams. | by Kalpa Senanayake
Meaning it will stop the sequence. Even if an error-handling operator is used, it does not allow the original sequence to continue.
Read more >Continue running ZStream after an error #7349 - zio/zio - GitHub
It doesn't make sense to restart the whole stream with in-flight elements in various processing stages just for a single failure. .either.mapZIO ...
Read more >RxJs Error Handling: Complete Practical Guide
As we can see, the stream emitted no value and it immediately errored out. After the error, no completion occurred. Limitations of the...
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 FreeTop 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
Top GitHub Comments
Check out this talk by Scott Wlaschin: https://youtu.be/E8I19uA-wGY?t=42m52s (about error handling from 42m) Best approach I’ve ever seen
Main problem i have met about errors is that stream is ending right after. All I can do is continue with another stream Cant do something like that with most.js (but can with any other frp library)
To be less abstract, example: I want to make a method, which take a stream of questions, and return a stream of answers (just fetch from wikipedia). So I want method like that:
getAnswers(questions$)
. But fetch can throw, so i need to handle error inside this method, that mean signature must be like thatgetAnswers$(questions$, onError)