-
Notifications
You must be signed in to change notification settings - Fork 84
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
Internal state breaks on errors within an on
listener?
#170
Comments
on
listener?
As of now you need to handle errors on your side. When an error occurs in a stream body the internal state of flyd is corrupted (the |
By "handle errors on your side", do you mean wrapping the contents of every subscribing function in a try/catch block? Hm. For what is worth, this case arose in my intentionally breaking stuff for my tests, and while the code is supposed to exit the process, for the tests of course I'm trying to avoid that. |
Duplicate of #164 For now, flyd gives atomic updates without any error handling. Exceptions inside a stream subscription function have no guarantee that any stream in that dependency graph will be valid in the end. For code that can fail, you'll need to wrap it in a try...catch -- this includes subscribed 'on' functions. |
Okay, thank you. |
I was getting the weirdest error, and it took me a while, but I reduced my code to this:
For which I get this output (Node v9.7.1):
Notice how the
letter
stream has the correct initial value both times, while the mapped streamuppercaseLetter
breaks after an exception is thrown. Both times the streams and everything else are recreated from scratch, so my guess is that something seriously breaks in flyd's internal state when an exception is thrown while runningon
listeners...By the way, thanks for flyd, and keep up the good work!
The text was updated successfully, but these errors were encountered: