{"action":"created","issue":{"url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/86","repository_url":"https://api.github.com/repos/alexhultman/uWebSockets","labels_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/86/comments","events_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/86/events","html_url":"https://github.com/alexhultman/uWebSockets/issues/86","id":152939408,"number":86,"title":"Possible race condition in handleUpgrade","user":{"login":"lpinca","id":1443911,"avatar_url":"https://avatars.githubusercontent.com/u/1443911?v=3","gravatar_id":"","url":"https://api.github.com/users/lpinca","html_url":"https://github.com/lpinca","followers_url":"https://api.github.com/users/lpinca/followers","following_url":"https://api.github.com/users/lpinca/following{/other_user}","gists_url":"https://api.github.com/users/lpinca/gists{/gist_id}","starred_url":"https://api.github.com/users/lpinca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpinca/subscriptions","organizations_url":"https://api.github.com/users/lpinca/orgs","repos_url":"https://api.github.com/users/lpinca/repos","events_url":"https://api.github.com/users/lpinca/events{/privacy}","received_events_url":"https://api.github.com/users/lpinca/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-04T06:31:44Z","updated_at":"2016-05-04T08:36:43Z","closed_at":null,"body":"Every upgrade request registers a new [`onConnection`](https://github.com/alexhultman/uWebSockets/blob/5793d5813da116b58f28911a2eecf73f34e43495/nodejs/dist/uws.js#L268-L278) handler, but [`server.upgrade`](https://github.com/alexhultman/uWebSockets/blob/5793d5813da116b58f28911a2eecf73f34e43495/nodejs/dist/uws.js#L286) is called asynchronously when the socket is closed.\r\n\r\nIf there are concurrent requests I think that it is possible that the wrong `onConnection` handler will be used.\r\n\r\nFor example if there are 2 concurrent requests they will both use the `onConnection` handler of the second one.\r\n\r\nI haven't tested this so I may be totally wrong."},"comment":{"url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/comments/216786946","html_url":"https://github.com/alexhultman/uWebSockets/issues/86#issuecomment-216786946","issue_url":"https://api.github.com/repos/alexhultman/uWebSockets/issues/86","id":216786946,"user":{"login":"lpinca","id":1443911,"avatar_url":"https://avatars.githubusercontent.com/u/1443911?v=3","gravatar_id":"","url":"https://api.github.com/users/lpinca","html_url":"https://github.com/lpinca","followers_url":"https://api.github.com/users/lpinca/followers","following_url":"https://api.github.com/users/lpinca/following{/other_user}","gists_url":"https://api.github.com/users/lpinca/gists{/gist_id}","starred_url":"https://api.github.com/users/lpinca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpinca/subscriptions","organizations_url":"https://api.github.com/users/lpinca/orgs","repos_url":"https://api.github.com/users/lpinca/repos","events_url":"https://api.github.com/users/lpinca/events{/privacy}","received_events_url":"https://api.github.com/users/lpinca/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T08:36:43Z","updated_at":"2016-05-04T08:36:43Z","body":"Yes that is also what I thought."}}