New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json decoding crashes the browser in 0.17 #571

Closed
ccapndave opened this Issue Apr 27, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@ccapndave

ccapndave commented Apr 27, 2016

I have found a case of Json decoding which causes the browser to crash (in fact it gets stuck in an infinite loop, the fan spins up and then you have to force quit it). This is the smallest test case I could come up with to reproduce it:

import Html exposing (text)
import Json.Decode as JD exposing (Decoder, (:=))
import Array exposing (Array)

json : String
json =
  """
  {
    "questions": [] 
  }
  """

main =
  let
    decoder : Decoder (Array String)
    decoder =
      ("questions" := JD.array JD.string)

    result : Result String (Array String)
    result =
      JD.decodeString decoder json
  in
  text <| toString result

I did some debugging, and it looks like the cause is in https://github.com/elm-lang/core/blob/dev/src/Native/Json.js#L239 - in this case it seems that problem.tag is undefined, and so the browser gets stuck in this while loop forever.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Apr 27, 2016

Contributor

Fixing this in #573.

@evancz, relevant for 0.17 release.

Contributor

jvoigtlaender commented Apr 27, 2016

Fixing this in #573.

@evancz, relevant for 0.17 release.

@evancz evancz closed this Apr 27, 2016

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Apr 27, 2016

Member

Thanks for the report @ccapndave

Member

evancz commented Apr 27, 2016

Thanks for the report @ccapndave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment