Skip to content

Instantly share code, notes, and snippets.

@klazuka

klazuka/Main.elm Secret

Created July 23, 2018 23:29
Show Gist options
  • Save klazuka/b824de5cf1551c1f567c627daa126f81 to your computer and use it in GitHub Desktop.
Save klazuka/b824de5cf1551c1f567c627daa126f81 to your computer and use it in GitHub Desktop.
Elm 0.19 debugger crash when browser blocks popup

Elm 0.19rc1 Browser.Debugger throws errors repeatedly when trying to open a popup if the browser (Chrome/Safari) is configured to block popups.

The problem is in _Debugger_openWindow on line 180. window.open() can return null for reasons, one of which being that the browser is blocking popups. On line 181 the value is used without checking for null.

Steps to reproduce:

  1. Make sure that your browser is blocking popups:
    • on Safari, open Preferences -> Security -> check 'Block pop-up windows'
    • on Chrome, open Preferences -> search for "popups" -> click "Content Settings" -> click "Popups" -> adjust settings
  2. elm make Main.elm --debug
  3. open index.html
  4. click "Explore History" in the corner
  5. check the JS console to observes 100s/1000s of errors being logged
{
"type": "application",
"source-directories": [
"."
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
module Main exposing (..)
import Browser
import Html exposing (text)
main =
Browser.sandbox
{ init = init
, view = view
, update = update
}
init = ()
type Msg = NoOp
update msg model =
case msg of
NoOp ->
model
view model =
text "hi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment