elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.54k stars 664 forks source link

Elm App History Export Corrupted in some 0.19 apps #1799

Open arsduo opened 6 years ago

arsduo commented 6 years ago

An example app I use (a slightly expanded version of the counter example) is experiencing a bug with Elm's debug history exports. Compiled with either elm-make or with webpack, clicking the counter buttons a few times and then exporting the history yields malform data like:

{
  "$": 0,
  "a": {
    "metadata": {
      "versions": {
        "elm": "0.19.0"
      },
      "types": {
        "message": "Main.Msg",
        "aliases": {},
        "unions": {
          "Main.Msg": {
            "args": [],
            "tags": {
              "Decrement": [],
              "Increment": [],
              "UpdateSecretField": [
                "String.String"
              ]
            }
          },
          "String.String": {
            "args": [],
            "tags": {
              "String": []
            }
          }
        }
      }
    },
    "history": [
      null,
      null,
      null,
      null,
      null
    ]
  }
}

The export function works fine for @rtfeldman's Elm SPA example, so it must be something subtle about this code, but for the life of me I can't figure it out.

Expected: the history field contains data about the messages that have been received

Actual: each entry is null.

SSCCE: https://github.com/arsduo/elm-history-export-bug

OS/browser: OS X 10.13.6, behavior consistent across Firefox/Chrome/Safari. A colleague was also able to reproduce this using the example on OS X.

elm-history-export-bug

elm-version
arsduo commented 5 years ago

FWIW I'm no longer seeing that problem -- instead, the history entries are being exported without the constructors.

For instance, I'm getting this:

{
  "history": [
    {
      "$": "Just",
      "a": "{\"authToken\":{\"access_token\":\"MY_TOKEN\"}}"
    }
  ]
}

instead of

{
  "history": [
    {
      "$": "StoredUserCredentialsRetrieved",
      "a": {
        "$": "Just",
        "a": "{\"authToken\":{\"access_token\":\"MY_TOKEN\"}}"
      }
    }
  ]
}