Skip to content

Debugger crashes when msg is triggered with large list in model #104

Open
@ChristophP

Description

@ChristophP

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
        }

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