{"action":"created","issue":{"url":"https://api.github.com/repos/ghcjs/ghcjs/issues/225","labels_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/225/labels{/name}","comments_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/225/comments","events_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/225/events","html_url":"https://github.com/ghcjs/ghcjs/issues/225","id":38181322,"number":225,"title":"h$shutdownHaskellAndExit doesn't work in browser, resulting with infinite loops","user":{"login":"osa1","id":448274,"avatar_url":"https://avatars.githubusercontent.com/u/448274?v=3","gravatar_id":"","url":"https://api.github.com/users/osa1","html_url":"https://github.com/osa1","followers_url":"https://api.github.com/users/osa1/followers","following_url":"https://api.github.com/users/osa1/following{/other_user}","gists_url":"https://api.github.com/users/osa1/gists{/gist_id}","starred_url":"https://api.github.com/users/osa1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osa1/subscriptions","organizations_url":"https://api.github.com/users/osa1/orgs","repos_url":"https://api.github.com/users/osa1/repos","events_url":"https://api.github.com/users/osa1/events{/privacy}","received_events_url":"https://api.github.com/users/osa1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ghcjs/ghcjs/labels/bug","name":"bug","color":"02e10c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-07-18T14:32:34Z","updated_at":"2015-10-19T00:25:16Z","closed_at":"2014-07-18T20:29:17Z","body":"Originally reported by trap_exit on IRC. Currently this bug is also blocking me.\r\n\r\nThis simple program:\r\n\r\n```haskell\r\nmain = error \"hello\"\r\n```\r\n\r\nFails to terminate on Chrom/Chromium and probably others. It prints \"If you can read this, shutdownHaskellAndExit did not exit.\" forever:\r\n\r\nhttps://github.com/ghcjs/ghcjs-boot/blob/master/patches/base.patch#L395\r\n\r\nThe problem is caused by this function in `shims/pkg/base.js`:\r\n\r\n```haskell\r\nfunction h$shutdownHaskellAndExit(code, fast) {\r\n    if(typeof process !== 'undefined' && process.exit) {\r\n        process.exit(code);\r\n    } else if(typeof quit !== 'undefined') {\r\n        quit(code);\r\n    }\r\n}\r\n```\r\n\r\nI think we need to somehow signal main loop to stop in this function, instead of forcing process to exit. 1) It may not possible to do that in browsers 2) even in node or other interpreters, stopping GHCJS main loop is different that terminating the whole app and I think what we should be doing is just stopping the GHCJS main loop and let rest of the program continue running."},"comment":{"url":"https://api.github.com/repos/ghcjs/ghcjs/issues/comments/149067494","html_url":"https://github.com/ghcjs/ghcjs/issues/225#issuecomment-149067494","issue_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/225","id":149067494,"user":{"login":"broma0","id":7075499,"avatar_url":"https://avatars.githubusercontent.com/u/7075499?v=3","gravatar_id":"","url":"https://api.github.com/users/broma0","html_url":"https://github.com/broma0","followers_url":"https://api.github.com/users/broma0/followers","following_url":"https://api.github.com/users/broma0/following{/other_user}","gists_url":"https://api.github.com/users/broma0/gists{/gist_id}","starred_url":"https://api.github.com/users/broma0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broma0/subscriptions","organizations_url":"https://api.github.com/users/broma0/orgs","repos_url":"https://api.github.com/users/broma0/repos","events_url":"https://api.github.com/users/broma0/events{/privacy}","received_events_url":"https://api.github.com/users/broma0/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T00:25:16Z","updated_at":"2015-10-19T00:25:16Z","body":"I'm still experiencing this using Google Chrome and Chromium on the <a href=\"https://github.com/ghcjs/ghcjs/tree/89ea7b2ffdcf441fb215d0582570327b3aa7b1b6\">latest commit</a> (as of writing this):\r\n\r\n<pre>main = error \"hello\"</pre>\r\n\r\nWas this fixed?"}}