Skip to content

What should happen if a canceler throws #110

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

Closed
natefaubion opened this issue Aug 20, 2017 · 5 comments
Closed

What should happen if a canceler throws #110

natefaubion opened this issue Aug 20, 2017 · 5 comments

Comments

@natefaubion
Copy link
Collaborator

For example, with the Alt instance, if a thread succeeds, but in the process of killing the other threads, one of them throws, should the entire Alt throw? Or should we throw the error in a fresh stack and continue with a success?

@natefaubion
Copy link
Collaborator Author

Right now, if a canceler throws in an Alt, the entire Alt will throw.

@jdegoes
Copy link
Contributor

jdegoes commented Aug 21, 2017

I think the failure to cancel an already completed result should not affect a branch of the Alt.

@natefaubion
Copy link
Collaborator Author

I think that's right. I did that for supervise but did not go back and do it for ParAff. The question I have now is, should errors during cancellation ever propagate? If I call kill on a thread, and a canceler somewhere throws, should the kill throw? I think that may not be desired, or even have sensible semantics because in the case of ParAff or supervise, where lots of threads may be killed as a result, it doesn't make sense to only propagate one of the errors if many of them may error. I'd prefer not to swallow exceptions unless recovery is part of the semantics of the operation. Perhaps it should instead always return with a success, but the error should be thrown in a fresh stack?

@jdegoes
Copy link
Contributor

jdegoes commented Aug 21, 2017

If I call kill on a thread, and a canceler somewhere throws, should the kill throw?

I don't think so. It would be nice to have a soft guarantee that kill never throws an exception.

Perhaps it should instead always return with a success, but the error should be thrown in a fresh stack?

There is an unresolved question (both here and in the Scala work I'm doing) of how to handle errors with no obvious output. Cancelers are one point (if semantics are changed as noted) but finalizers are another. Finalizers must always be run, inner to outer, even if inner finalizers fail. Now these errors disappear into a black hole.

Javascript has window.onerror which is one potential sink to dump these global errors into, lacking a better alternative.

@natefaubion
Copy link
Collaborator Author

Javascript has window.onerror which is one potential sink to dump these global errors into, lacking a better alternative.

Yes that's the idea. I don't want to swallow errors, and JS runtimes at least have a global handler to observe exceptions like this. It's possible we could add our own thing as well, but I don't really want to do that unless we find it's really necessary.

natefaubion added a commit to natefaubion/purescript-aff that referenced this issue Aug 22, 2017
Fixes purescript-contrib#110
Fixes purescript-contrib#113

This handles bracket/catch within finalizers by tagging all items in the
attempt stack with the interrupt status. When we go to evaluate them we
can then compare if the interrupt status has changed and whether we
should filter it out or run it.
@natefaubion natefaubion mentioned this issue Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants