core icon indicating copy to clipboard operation
core copied to clipboard

Trying to kill a Process that has already run will cause Javascript Error

Open rl-king opened this issue 6 years ago • 3 comments

Sscce

https://ellie-app.com/4J8FNh7TMa1/2 https://ellie-app.com/5986pv2Mma1/0 by @zwilias

Error

TypeError: null is not an object (evaluating 'root.ctor')

Possibly related

#706

rl-king avatar Apr 02 '18 21:04 rl-king

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot avatar Apr 02 '18 21:04 process-bot

This is still an issue in elm 0.19.

Here is @zwilias's sscce updated for 0.19:

module Main exposing (..)

import Html exposing (text)
import Process
import Task exposing (Task)


killProcessTwice : Task Never ()
killProcessTwice =
    Task.succeed ()
        |> Process.spawn
        |> Task.andThen
            (\pid ->
                Process.kill pid
                    |> Task.andThen (\_ -> Process.kill pid)
            )


main =
    Html.program
        { init =
            ( ()
            , Task.perform (always ()) killProcessTwice
            )
        , view = \_ -> text "oops"
        , update = \_ model -> model ! []
        , subscriptions = \_ -> Sub.none
        }

Running in https://ellie-app.com/3mGSw3SWLbca1 gives TypeError: task is null, can't access property "$" of it

harrysarson avatar Sep 16 '18 11:09 harrysarson

Applogies: the sscce above has not infact been updated for elm 19.

This one has: https://ellie-app.com/4CzFx6NYkrSa1

module Main exposing (..)

import Html exposing (text)
import Process
import Task exposing (Task)
import Browser


killProcessTwice : Task Never ()
killProcessTwice =
    Task.succeed ()
        |> Process.spawn
        |> Task.andThen
            (\pid ->
                Process.kill pid
                    |> Task.andThen (\_ -> Process.kill pid)
            )


main =
    Browser.element
        { init = \() ->
            ( ()
            , Task.perform (always ()) killProcessTwice
            )
        , view = \_ -> text "oops"
        , update = \_ model -> (model, Cmd.none)
        , subscriptions = \_ -> Sub.none
        }

harrysarson avatar Feb 02 '19 12:02 harrysarson