browser icon indicating copy to clipboard operation
browser copied to clipboard

Debugger crashes when msg is triggered with large list in model

Open ChristophP opened this issue 5 years ago • 2 comments

What's the bug? The debugger seems to compare the old and new model whenever a new msg is triggered. When the model contains a large list it can throw a Maximum Call Stack size exceeded exception.

Other information

  • Happens only when the debugger is enabled
  • Depends on the call stack size limit of the browser. A list of length 5000 is enough to trigger the error on my Mac using Chrome v80
  • The error does not occur for a lower number(say 100)
  • The bug occurred using elm 0.19.1, elm/core 1.0.5 and elm/browser 1.0.2
  • The exact error msg is this: grafik

SSCCE

module Main exposing (..)

import Browser
import Html exposing (Html, button, text)
import Html.Events exposing (onClick)


type Msg
    = ButtonClicked


type alias Model =
    { longList : List () }


list =
    let
        {- Play with the listLength parameter to see that it works for smaller numbers.
           Crashes in Chrome v80 with listLength = 5000
        -}
        listLength =
            5000
    in
    List.range 0 listLength |> List.map (always ())


main =
    Browser.document
        { init = \() -> ( { longList = list }, Cmd.none )
        , update =
            \msg model ->
                case msg of
                    ButtonClicked ->
                        ( model, Cmd.none )
        , view =
            \_ ->
                Browser.Document "SWK NL Segmentation"
                    [ button [ onClick ButtonClicked ] [ text "Click me" ] ]
        , subscriptions = \_ -> Sub.none
        }

ChristophP avatar Feb 26 '20 12:02 ChristophP

May be resolved by this PR #95

ChristophP avatar Feb 26 '20 21:02 ChristophP

Looks like a duplicate of #90 (which also has a fix, #120).

jerith666 avatar Sep 24 '21 02:09 jerith666