-
Notifications
You must be signed in to change notification settings - Fork 65
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
Exceptions in pure code #172
Comments
@natefaubion you mentioned performance concerns w.r.t. adding try/catches to deal with such programming errors. Is this something you've quantified (or that we could try to)? Might help make a more informed decision about the cost. |
There are some basic benchmarks in the test directory for pure binds. I would run it as is, apply a try/catch around the |
Thanks @natefaubion -- I don't see a perf impact in the benchmark. |
This bug just cost me two days, so I wouldn't mind it being merged. |
This puts a try-catch around the bind step in order to try to catch code that is not expected to have effects but does (by throwing). While this is clearly a programming error, it is certainly not implausible that effects creep into FFI code inadvertently for Aff users. This allows us to be defensive in that case and recover, rather than have all asynchronous options quitely not work after. The addition of the try-catch does not seem to have a performance impact (tested on Node v10.15.3). With and without this change, `pulp test` takes ~4.8s to run. There is a discussion around this on #172.
Closed by #173 |
Currently, if we have bad code that throws an exception despite being annotated as being pure, it seems to put
Aff
into a bad state where no more callbacks occur. I've written up an example at:This is of course just bad code, but it might make sense to be defensive against this if there isn't a significant cost, as there are cases with a significant surface of JS interop, which can make for more common programming errors.
The text was updated successfully, but these errors were encountered: