{"action":"created","issue":{"url":"https://api.github.com/repos/seishun/node-steam/issues/270","labels_url":"https://api.github.com/repos/seishun/node-steam/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/seishun/node-steam/issues/270/comments","events_url":"https://api.github.com/repos/seishun/node-steam/issues/270/events","html_url":"https://github.com/seishun/node-steam/pull/270","id":112068522,"number":270,"title":"fix(web-api-nonce): crash caused by authing with web api","user":{"login":"Cohedrin","id":8690766,"avatar_url":"https://avatars.githubusercontent.com/u/8690766?v=3","gravatar_id":"","url":"https://api.github.com/users/Cohedrin","html_url":"https://github.com/Cohedrin","followers_url":"https://api.github.com/users/Cohedrin/followers","following_url":"https://api.github.com/users/Cohedrin/following{/other_user}","gists_url":"https://api.github.com/users/Cohedrin/gists{/gist_id}","starred_url":"https://api.github.com/users/Cohedrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cohedrin/subscriptions","organizations_url":"https://api.github.com/users/Cohedrin/orgs","repos_url":"https://api.github.com/users/Cohedrin/repos","events_url":"https://api.github.com/users/Cohedrin/events{/privacy}","received_events_url":"https://api.github.com/users/Cohedrin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-19T04:09:42Z","updated_at":"2015-10-19T18:10:13Z","closed_at":"2015-10-19T18:10:13Z","pull_request":{"url":"https://api.github.com/repos/seishun/node-steam/pulls/270","html_url":"https://github.com/seishun/node-steam/pull/270","diff_url":"https://github.com/seishun/node-steam/pull/270.diff","patch_url":"https://github.com/seishun/node-steam/pull/270.patch"},"body":"Resolves #234\r\n\r\nThis error is thrown when a callback calls [#requestWebAPIAuthenticateUserNonce](https://github.com/seishun/node-steam/blob/master/lib/handlers/user/index.js#L36), after the client as been disconnected from steam.\r\n\r\nThis message requires both `steamID` and `sessionID` to be set, but when the client is disconnected they are both unset, causing this header to be sent:\r\n```\r\n{ msg: 5585,\r\n  proto:\r\n   { client_sessionid: 0,\r\n     steamid: '76561197960265728',\r\n     jobid_source: 1 } }\r\n```\r\n(`76561197960265728` is the base steamID, generated [here](https://github.com/seishun/node-steam/blob/master/lib/handlers/user/index.js#L23-L27))\r\n\r\nThis causes this header to be received with no body.\r\n```\r\n{ msg: 113,\r\n  headerSize: 36,\r\n  headerVersion: 2,\r\n  targetJobID: { low: 1, high: 0, unsigned: true },\r\n  sourceJobID: { low: -1, high: -1, unsigned: true },\r\n  headerCanary: -17,\r\n  steamID: { low: 0, high: 0, unsigned: true }\r\n```\r\n\r\nWhich is just the default destination job failed header.\r\n\r\nObviously this will make whatever callback the user passes to be never called, but any code that would be calling this method should be happening after the `logOnResponse` event is fired, so it will be retriggered once the client is logged back in.\r\n\r\n### Reproduction \r\nReproducing this is tricky, as it's all timing. However, a way to cause this to happen is start a client that calls #requestWebAPIAuthenticateUserNonce, then start another client with the same steamID. This will disconnect the first client, allowing this error to be reproduced."},"comment":{"url":"https://api.github.com/repos/seishun/node-steam/issues/comments/149300949","html_url":"https://github.com/seishun/node-steam/pull/270#issuecomment-149300949","issue_url":"https://api.github.com/repos/seishun/node-steam/issues/270","id":149300949,"user":{"login":"seishun","id":988441,"avatar_url":"https://avatars.githubusercontent.com/u/988441?v=3","gravatar_id":"","url":"https://api.github.com/users/seishun","html_url":"https://github.com/seishun","followers_url":"https://api.github.com/users/seishun/followers","following_url":"https://api.github.com/users/seishun/following{/other_user}","gists_url":"https://api.github.com/users/seishun/gists{/gist_id}","starred_url":"https://api.github.com/users/seishun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seishun/subscriptions","organizations_url":"https://api.github.com/users/seishun/orgs","repos_url":"https://api.github.com/users/seishun/repos","events_url":"https://api.github.com/users/seishun/events{/privacy}","received_events_url":"https://api.github.com/users/seishun/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T18:10:13Z","updated_at":"2015-10-19T18:10:13Z","body":"In that case, I can't accept this PR. As stated [here](https://github.com/seishun/node-steam#loggedon):\r\n\r\n>Calling any handler methods other than SteamUser#logOn is only allowed while logged on.\r\n\r\nThere are countless ways things can go wrong if the library is used incorrectly. No point working around just one of them. What users should do is something like the following:\r\n\r\n```js\r\nif (client.loggedOn) {\r\n  user.requestWebAPIAuthenticateUserNonce(callback);\r\n} else {\r\n  // some logic depending on the context\r\n}\r\n```"}}