Skip to content

Suspicious supervision behaviour during cancellation #146

New issue

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

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

Already on GitHub? # to your account

Closed
felixSchl opened this issue Apr 19, 2018 · 1 comment
Closed

Suspicious supervision behaviour during cancellation #146

felixSchl opened this issue Apr 19, 2018 · 1 comment

Comments

@felixSchl
Copy link

felixSchl commented Apr 19, 2018

Hey, I've been running into issues with fork cancellation and supervisors and decided to spend some time narrowing the issue down. Below are two snippets highlighting what I would consider strange behaviour. It's not obvious to me why this behaviour occurs and looks like a bug on the surface.

The following snippet throws off-stack, due to:
https://github.com/slamdata/purescript-aff/blob/3457df9993a78e408ed56f0bb619941911d375d0/src/Control/Monad/Aff.js#L500-L505

        outer <- forkAff do
          bracket
            (pure unit)
            (const $ pure unit)
            \_ -> supervise do
              fiber <- forkAff $ supervise $ supervise do -- notice the double 'supervise'
                delay $ 10.0 # Milliseconds
              joinFiber fiber
        killFiber (error "done") outer
        delay $ 100.0 # Milliseconds

and this blocks forever:

        outer <- forkAff do
          bracket
            (pure unit)
            (const $ pure unit)
            \_ -> supervise do
              fiber <- forkAff $ supervise do
                delay $ 10.0 # Milliseconds
              joinFiber fiber
        killFiber (error "doen") outer
        delay $ 100.0 # Milliseconds

You can play around with these, but from my observations this only happens when inside a bracket, but the problem is probably broader.

@natefaubion
Copy link
Collaborator

I think this is because Supervisor does not handle the case where there are no forks, so it never invokes the callback.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants