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

Stream throws instead of calling error listener when using .map #178

Closed
lachenmayer opened this issue Mar 31, 2017 · 2 comments
Closed

Stream throws instead of calling error listener when using .map #178

lachenmayer opened this issue Mar 31, 2017 · 2 comments

Comments

@lachenmayer
Copy link

Hi there, I'm not sure if this a bug or intended behaviour.

I have a stream of things, and I'm calling a validation function (eg. isValid) which may throw.

This is the expected behavior:

thing$
  .filter(isValid)
  .addListener({next: console.log, error: console.error})
// error is printed using error listener

However, when I try to add a map operator, the error does not get passed to the error listener, as expected. The exception is not handled at all.

thing$
  .filter(isValid)
+  .map(x => {type: 'success', payload: x})
  .addListener({next: console.log, error: console.error})
// throws!

I've tried using other operators like take or another filter, after the initial (throwing) filter, and those work as expected, ie. the error listener is called.

Here is an executable example, if this is unclear: https://runkit.com/lachenmayer/xstream-error-handling

version: 10.3.0

@staltz
Copy link
Owner

staltz commented Mar 31, 2017

Oh it seems like we missed a try catch

if (!this.passes(t)) return;

Certainly a bug and certainly fixable

staltz added a commit that referenced this issue Apr 3, 2017
Operator fusion such as filter+map or map+flatten has been causing bugs to users, such as #165 and
#178. Since this library's focus is not "as high performance as possible", we need to prioritize
correctness and library size. Removing operator fusion should solve the mentioned issues besides
others not reported.

#165 and #178
@staltz
Copy link
Owner

staltz commented Apr 3, 2017

This is now fixed in xstream v10.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants