Errors within subscriptions
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Documentation Related To Component:
https://rxjs-dev.firebaseapp.com/guide/subscription
Please check those that apply
- typo
- documentation doesn't exist
- documentation needs clarification
- error(s) in example
- needs example
Description Of The Issue
It's unclear to me what is meant to happen to happen if an error is thrown inside a subscription:
const logWithPrecision = i => console.log(i.toPrecision(2));
const logError = () => console.error(`Error in execution`);
const strings = interval(750).pipe(
take(3),
map(i => i.toString())
);
const numbers = interval(300).pipe(take(3));
merge(strings, numbers).subscribe(logWithPrecision, logError);
// 0.0
// 1.0
// ).subscribe((i: any) => console.log(i.toPrecision(2)));
// ^
// TypeError: i.toPrecision is not a function
// ...
I might expect the error to be handled by the error handler, logError, as it would be with a promise:
new Promise(r => r('0')).then(logWithPrecision).catch(logError);
// Error in execution
I wouldn't expect the subscription to stop -- instead I would expect the final value from numbers to be logged, followed by a few more errors from the strings stream.
How are errors within a subscription meant to be handled? Is the subscription expected to stop, and should the complete callback be called?
This documentation seems related, but I am not familiar with the context as I have not used v5x.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the subscription guide linked in the issue and compare it with the v6 migration example. Clarify how errors thrown inside a subscription are handled, including whether the subscription stops and whether completion is called, then update the documentation with a verified example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100