Skip to content

Exception when trying to kill fiber from its own fork code #217

Open
@m-bock

Description

@m-bock

Describe the bug
The excpetion "TypeError: step is not a function" is thrown when a fiber is killed from its own fork code:

main :: Effect Unit
main = launchAff_ do
  ref <- liftEffect $ Ref.new Nothing

  fib <- forkAff do
    delay (Milliseconds 500.0)
    maybeFib <- liftEffect $ Ref.read ref

    case maybeFib of
      Just fib -> do
        killFiber (Aff.error "killed") fib
      Nothing -> do
        pure unit

    pure unit

  liftEffect $ Ref.write (Just fib) ref

  delay (Milliseconds 1000.0)

To Reproduce

  1. Open complete minimal reproducible example on Try PureScript

  2. Open the dev console, it shows the Error:

foreign.js:521 Uncaught TypeError: step is not a function
    at foreign.js:590:59
    at foreign.js:10:16
    at foreign.js:10:20
    at runAsync (foreign.js:96:20)
    at run (foreign.js:331:22)
    at foreign.js:346:19
    at drain (foreign.js:118:9)
    at Object.enqueue (foreign.js:139:11)
    at foreign.js:337:27

Expected behavior
There should be no error in the console.

Additional context
Happens in node and in the browser.

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