Is Process package ready to use?

I want to have API like setTimeout/clearTimeout. So I created an example:

https://ellie-app.com/6Xp3Rn3n3a1/0

It consists of two buttons - “Press me” (which starts timeout via Process.sleep and Process.spawn) and “StopTimeout” (which double kills the timeout)

Previously I killed timeout once, but I faced runtime exception when I tried to kill the same timeout twice.
So I decided to kill twice in the example in order to reproduce this behavior.

Is this an expected behavior to crash app on double process kill?

I didn’t get any feedback, so there is a little more details:

This is part of my update function:

   case msg of
        SetTimeout ->
            let
                sleepTask =
                    Process.sleep (5 * Time.second)

                spawnTask =
                    Process.spawn sleepTask
            in
            ( { model | timedOut = False, sleepTask = Just sleepTask }
            , Cmd.batch
                [ Task.perform TimedOut sleepTask
                , Task.perform GotId spawnTask
                ]
            )

        StopTimeout ->
            case model.timeoutId of
                Nothing ->
                    ( model, Cmd.none )

                Just id ->
                    ( { model | timeoutId = Nothing }
                    , Cmd.batch
                        [ Task.perform Killed <| Process.kill id
                        , Task.perform Killed <| Process.kill id
                        ]
                    )
        -- ...
        GotId id ->
            ( { model | timeoutId = Just id }, Cmd.none )

Here is the error I get:
Uncaught TypeError: Cannot read property 'ctor' of null

And there is the question:
Is it appropriate behavoir for Process package or just a bug?

An Elm app shouldn’t crash during runtime, expect for a few edge cases ™, so I think it’s safe to say this is a bug. Perhaps you should open an issue on elm/core

EDIT: Evan pointed out that an issue already exists. I searched for this issue in the complier’s repo and didn’t find any related issues. I should have searched elm/core too!

There is one https://github.com/elm/core/issues/955

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.