{"action":"created","issue":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/5282","repository_url":"https://api.github.com/repos/nwjs/nw.js","labels_url":"https://api.github.com/repos/nwjs/nw.js/issues/5282/labels{/name}","comments_url":"https://api.github.com/repos/nwjs/nw.js/issues/5282/comments","events_url":"https://api.github.com/repos/nwjs/nw.js/issues/5282/events","html_url":"https://github.com/nwjs/nw.js/issues/5282","id":175558521,"number":5282,"title":"Crash when showing an alert","user":{"login":"kohenkatz","id":88755,"avatar_url":"https://avatars.githubusercontent.com/u/88755?v=3","gravatar_id":"","url":"https://api.github.com/users/kohenkatz","html_url":"https://github.com/kohenkatz","followers_url":"https://api.github.com/users/kohenkatz/followers","following_url":"https://api.github.com/users/kohenkatz/following{/other_user}","gists_url":"https://api.github.com/users/kohenkatz/gists{/gist_id}","starred_url":"https://api.github.com/users/kohenkatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohenkatz/subscriptions","organizations_url":"https://api.github.com/users/kohenkatz/orgs","repos_url":"https://api.github.com/users/kohenkatz/repos","events_url":"https://api.github.com/users/kohenkatz/events{/privacy}","received_events_url":"https://api.github.com/users/kohenkatz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nwjs/nw.js/labels/bug","name":"bug","color":"e10c02"},{"url":"https://api.github.com/repos/nwjs/nw.js/labels/test-todo","name":"test-todo","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"rogerwang","id":165401,"avatar_url":"https://avatars.githubusercontent.com/u/165401?v=3","gravatar_id":"","url":"https://api.github.com/users/rogerwang","html_url":"https://github.com/rogerwang","followers_url":"https://api.github.com/users/rogerwang/followers","following_url":"https://api.github.com/users/rogerwang/following{/other_user}","gists_url":"https://api.github.com/users/rogerwang/gists{/gist_id}","starred_url":"https://api.github.com/users/rogerwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogerwang/subscriptions","organizations_url":"https://api.github.com/users/rogerwang/orgs","repos_url":"https://api.github.com/users/rogerwang/repos","events_url":"https://api.github.com/users/rogerwang/events{/privacy}","received_events_url":"https://api.github.com/users/rogerwang/received_events","type":"User","site_admin":false},"assignees":[{"login":"rogerwang","id":165401,"avatar_url":"https://avatars.githubusercontent.com/u/165401?v=3","gravatar_id":"","url":"https://api.github.com/users/rogerwang","html_url":"https://github.com/rogerwang","followers_url":"https://api.github.com/users/rogerwang/followers","following_url":"https://api.github.com/users/rogerwang/following{/other_user}","gists_url":"https://api.github.com/users/rogerwang/gists{/gist_id}","starred_url":"https://api.github.com/users/rogerwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogerwang/subscriptions","organizations_url":"https://api.github.com/users/rogerwang/orgs","repos_url":"https://api.github.com/users/rogerwang/repos","events_url":"https://api.github.com/users/rogerwang/events{/privacy}","received_events_url":"https://api.github.com/users/rogerwang/received_events","type":"User","site_admin":false},{"login":"ghostoy","id":471928,"avatar_url":"https://avatars.githubusercontent.com/u/471928?v=3","gravatar_id":"","url":"https://api.github.com/users/ghostoy","html_url":"https://github.com/ghostoy","followers_url":"https://api.github.com/users/ghostoy/followers","following_url":"https://api.github.com/users/ghostoy/following{/other_user}","gists_url":"https://api.github.com/users/ghostoy/gists{/gist_id}","starred_url":"https://api.github.com/users/ghostoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghostoy/subscriptions","organizations_url":"https://api.github.com/users/ghostoy/orgs","repos_url":"https://api.github.com/users/ghostoy/repos","events_url":"https://api.github.com/users/ghostoy/events{/privacy}","received_events_url":"https://api.github.com/users/ghostoy/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2016-09-07T17:16:03Z","updated_at":"2016-09-14T11:58:44Z","closed_at":null,"body":"I have tested this on Windows 10 x64 and MacOS (whatever the most recent is, I don't remember), in NW.js versions 0.17.0 and 0.14.7. All of those combinations have the following problem.\r\n\r\nI have an application that is using NW.js to show a website to users who do not have Chrome installed on their machines. The website opens a WebSocket connection to another server. If the server closes the WebSocket, the website shows an `alert`, clears its session, and redirects the user back to the login page.\r\n\r\nWhen the `alert` is supposed to show, NW.js crashes with the following messages on the console:\r\n\r\n```\r\n[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d6c00000000, size 0x1f1 fully unreadable\r\n[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d8c00000000, size 0x1f1 fully unreadable\r\n[0907/125520:ERROR:process_info.cc(608)] range at 0x42d2d8e00000000, size 0x1f1 fully unreadable\r\n\r\nnw.js exits with code 3221225477.\r\n```\r\n\r\n(The `range at 0xXXXX, size 0xXXX` numbers vary, but all the rest is the same.)\r\n\r\n\r\nFor background, here's the (ES6 version of the) code for the WebSocket handler. The actual project uses a transpiled ES5 version because it has to run in browsers, but this should be all that is needed for illustration of the issue.\r\n\r\n```\r\nimport WildEmitter from 'wildemitter';\r\n\r\nexport default class SocketManager {\r\n\tconstructor(url, username, password) {\r\n\t\tthis._ws = new WebSocket(url);\r\n\r\n\t\tthis._ws.onopen = (evt) => {\r\n\t\t\tthis.send({\r\n\t\t\t  type: 'connect',\r\n\t\t\t  user: username,\r\n\t\t\t  pass: password\r\n\t\t\t});\r\n\t\t};\r\n\r\n\t\tthis._ws.onerror = (evt) => {\r\n\t\t\tthis.emit('error', evt);\r\n\t\t};\r\n\r\n\t\tthis._ws.onclose = (evt) => {\r\n\t\t\tthis.emit('closed');\r\n\t\t};\r\n\t\tthis._ws.onmessage = ({data: data}) => {\r\n\t\t\tvar obj = null;\r\n\t\t\ttry {\r\n\t\t\t\tobj = JSON.parse(data);\r\n\t\t\t} catch(err) {\r\n\t\t\t\tthis.emit('error', `invalid message: ${data}`);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tif (obj.type) {\r\n\t\t\t\tthis.emit(`message.${obj.type}`, obj);\r\n\t\t\t} else {\r\n\t\t\t\tthis.emit('message.unknown_type', obj);\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t}\r\n\r\n\tsend(message) {\r\n\t\tif (this._ws && this._ws.readyState === WebSocket.OPEN) {\r\n\t\t\tvar messageStr = JSON.stringify(message);\r\n\t\t\tthis.emit('sending', messageStr);\r\n\t\t\tthis._ws.send(messageStr);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to send on WebSocket: WebSocket is not open');\r\n\t\t}\r\n\t}\r\n\r\n\tclose() {\r\n\t\tif (this._ws) {\r\n\t\t\treturn this._ws.close();\r\n\t\t} else {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nWildEmitter.mixin(SocketManager);\r\n```\r\n\r\nHere is the code where the crash occurs:\r\n\r\n```\r\nsocket.on('message.error', function(message) {\r\n\talert(message.errorText);\r\n});\r\n```\r\n\r\n<strike>The crash happens just before the native WebSocket `onclose` event would be fired - breakpoints in the DevTools show that the last incoming message is received and then the crash happens before the breakpoint on `this.emit('closed');` (inside `this._ws.onclose`) can be reached.</strike>\r\n\r\n\r\nThe website works fine in Chrome, in all versions released in the last 8 months.\r\n\r\nHere are some crash dumps: [reports.zip](https://github.com/nwjs/nw.js/files/459829/reports.zip)\r\n"},"comment":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/comments/246990381","html_url":"https://github.com/nwjs/nw.js/issues/5282#issuecomment-246990381","issue_url":"https://api.github.com/repos/nwjs/nw.js/issues/5282","id":246990381,"user":{"login":"kohenkatz","id":88755,"avatar_url":"https://avatars.githubusercontent.com/u/88755?v=3","gravatar_id":"","url":"https://api.github.com/users/kohenkatz","html_url":"https://github.com/kohenkatz","followers_url":"https://api.github.com/users/kohenkatz/followers","following_url":"https://api.github.com/users/kohenkatz/following{/other_user}","gists_url":"https://api.github.com/users/kohenkatz/gists{/gist_id}","starred_url":"https://api.github.com/users/kohenkatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohenkatz/subscriptions","organizations_url":"https://api.github.com/users/kohenkatz/orgs","repos_url":"https://api.github.com/users/kohenkatz/repos","events_url":"https://api.github.com/users/kohenkatz/events{/privacy}","received_events_url":"https://api.github.com/users/kohenkatz/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T11:58:44Z","updated_at":"2016-09-14T11:58:44Z","body":"@ghostoy Thank you"}}
{"actor":{"display_login":"kohenkatz"}}