Skip to content

Suspicious supervision behaviour during cancellation #146

Closed
@felixSchl

Description

@felixSchl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions