elm / browser

Create Elm programs that run in browsers!
https://package.elm-lang.org/packages/elm/browser/latest/
BSD 3-Clause "New" or "Revised" License
312 stars 64 forks source link

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

Open ChristophP opened 4 years ago

ChristophP commented 4 years ago

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

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 commented 4 years ago

May be resolved by this PR #95

jerith666 commented 2 years ago

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