Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLIBZ-2323: Thrown error in onNext() in observable causes silent observable unsubscribe #302

Merged
merged 3 commits into from
May 31, 2018

Conversation

thomasconner
Copy link
Contributor

@thomasconner thomasconner commented May 29, 2018

Description

When an error in the onNext() function is thrown, the error is silently handled by the SDK and an unsubscribe from the observable is called, thus leaving the developer without notification that something went wrong.

A running sample describing the above can be found here. Without a try-catch block, trying to access a property from the returned entities will cause an error as the first fetched result would be from the localStorage and thus an empty array. The thrown error will not be shown to the developer causing a silent unsubscribe from the observable.

Changes

  • Don't swallow errors caused in the onNext() function for an Observable

Tests

  • Added test to check that an error is not swallowed when created in the onNext() function

@thomasconner thomasconner self-assigned this May 29, 2018
Copy link
Contributor

@vinaygahlawat vinaygahlawat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, but just have one question to be answered before approval.

@@ -128,7 +128,7 @@ class SafeSubscriber extends Subscriber {
try {
fn.call(this._context, value);
} catch (err) {
this.unsubscribe();
this.error(err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to throw an error here. But are there certain cases where we should still unsubscribe, or is this now something the developer should handle completely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will still unsubscribe after the error callback is called.

Copy link
Contributor

@vinaygahlawat vinaygahlawat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomasconner thomasconner merged commit c0889a0 into master May 31, 2018
@thomasconner thomasconner deleted the MLIBZ-2323 branch May 31, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants