{"action":"opened","number":122,"pull_request":{"url":"https://api.github.com/repos/ably/ably-js/pulls/122","id":44356373,"html_url":"https://github.com/ably/ably-js/pull/122","diff_url":"https://github.com/ably/ably-js/pull/122.diff","patch_url":"https://github.com/ably/ably-js/pull/122.patch","issue_url":"https://api.github.com/repos/ably/ably-js/issues/122","number":122,"state":"open","locked":false,"title":"Don't process duplicate messages or messages on inactive transports","user":{"login":"SimonWoolf","id":5908687,"avatar_url":"https://avatars.githubusercontent.com/u/5908687?v=3","gravatar_id":"","url":"https://api.github.com/users/SimonWoolf","html_url":"https://github.com/SimonWoolf","followers_url":"https://api.github.com/users/SimonWoolf/followers","following_url":"https://api.github.com/users/SimonWoolf/following{/other_user}","gists_url":"https://api.github.com/users/SimonWoolf/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonWoolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonWoolf/subscriptions","organizations_url":"https://api.github.com/users/SimonWoolf/orgs","repos_url":"https://api.github.com/users/SimonWoolf/repos","events_url":"https://api.github.com/users/SimonWoolf/events{/privacy}","received_events_url":"https://api.github.com/users/SimonWoolf/received_events","type":"User","site_admin":false},"body":"So, in new-upgrade, sometimes you get duplicate messages from realtime due to races. (Eg: a new transport is made active, it sends a sync message with connectionSerial -1, it receives a new action:15 message with connectionSerial 0, realtime processes the sync and sends that message again. Most of the tests in spec/realtime/message.test.js (run against local realtime for less lag to make it more likely) can show this behaviour.)\r\n\r\nBut that shouldn't be a problem: the messages have the same connectionSerial, so the client should just discard the second one. Isn't that part of the point of a connectionSerial? But it currently doesn't: messages are processed even if their connectionSerial is <= the client's connectionSerial.\r\n\r\nIn addition, messages are processed even if they come through on a no-longer-active transport (although in that case the client's connectionSerial is not updated). So just adding a check for connectionSerial isn't enough, as then you have a race condition where, say, closing the connection clears the connection state (which sets the connectionSerial to `undefined`) - and then a message comes in on that transport and gets processed, even though the connection's nominally closed, as the connectionManager can't tell it's a duplicate due to lack of a connectionSerial. Why do we want messages coming in on inactive transports to be processed at all?","created_at":"2015-09-07T13:41:20Z","updated_at":"2015-09-07T13:41:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ably/ably-js/pulls/122/commits","review_comments_url":"https://api.github.com/repos/ably/ably-js/pulls/122/comments","review_comment_url":"https://api.github.com/repos/ably/ably-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ably/ably-js/issues/122/comments","statuses_url":"https://api.github.com/repos/ably/ably-js/statuses/76dee8722804357cd9905a3809c032518e088ed9","head":{"label":"ably:duplicate-messages","ref":"duplicate-messages","sha":"76dee8722804357cd9905a3809c032518e088ed9","user":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"repo":{"id":6676523,"name":"ably-js","full_name":"ably/ably-js","owner":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ably/ably-js","description":"Ably Realtime Messaging Javascript library to connect from your browser or Node.js","fork":false,"url":"https://api.github.com/repos/ably/ably-js","forks_url":"https://api.github.com/repos/ably/ably-js/forks","keys_url":"https://api.github.com/repos/ably/ably-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ably/ably-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ably/ably-js/teams","hooks_url":"https://api.github.com/repos/ably/ably-js/hooks","issue_events_url":"https://api.github.com/repos/ably/ably-js/issues/events{/number}","events_url":"https://api.github.com/repos/ably/ably-js/events","assignees_url":"https://api.github.com/repos/ably/ably-js/assignees{/user}","branches_url":"https://api.github.com/repos/ably/ably-js/branches{/branch}","tags_url":"https://api.github.com/repos/ably/ably-js/tags","blobs_url":"https://api.github.com/repos/ably/ably-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ably/ably-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ably/ably-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ably/ably-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ably/ably-js/statuses/{sha}","languages_url":"https://api.github.com/repos/ably/ably-js/languages","stargazers_url":"https://api.github.com/repos/ably/ably-js/stargazers","contributors_url":"https://api.github.com/repos/ably/ably-js/contributors","subscribers_url":"https://api.github.com/repos/ably/ably-js/subscribers","subscription_url":"https://api.github.com/repos/ably/ably-js/subscription","commits_url":"https://api.github.com/repos/ably/ably-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ably/ably-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ably/ably-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ably/ably-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ably/ably-js/contents/{+path}","compare_url":"https://api.github.com/repos/ably/ably-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ably/ably-js/merges","archive_url":"https://api.github.com/repos/ably/ably-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ably/ably-js/downloads","issues_url":"https://api.github.com/repos/ably/ably-js/issues{/number}","pulls_url":"https://api.github.com/repos/ably/ably-js/pulls{/number}","milestones_url":"https://api.github.com/repos/ably/ably-js/milestones{/number}","notifications_url":"https://api.github.com/repos/ably/ably-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ably/ably-js/labels{/name}","releases_url":"https://api.github.com/repos/ably/ably-js/releases{/id}","created_at":"2012-11-13T19:41:13Z","updated_at":"2015-05-06T17:34:22Z","pushed_at":"2015-09-07T13:36:06Z","git_url":"git://github.com/ably/ably-js.git","ssh_url":"git@github.com:ably/ably-js.git","clone_url":"https://github.com/ably/ably-js.git","svn_url":"https://github.com/ably/ably-js","homepage":null,"size":11951,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":31,"forks":1,"open_issues":31,"watchers":0,"default_branch":"master"}},"base":{"label":"ably:new-upgrade","ref":"new-upgrade","sha":"03734179114a30948bee566a7e034de253628f96","user":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"repo":{"id":6676523,"name":"ably-js","full_name":"ably/ably-js","owner":{"login":"ably","id":1859245,"avatar_url":"https://avatars.githubusercontent.com/u/1859245?v=3","gravatar_id":"","url":"https://api.github.com/users/ably","html_url":"https://github.com/ably","followers_url":"https://api.github.com/users/ably/followers","following_url":"https://api.github.com/users/ably/following{/other_user}","gists_url":"https://api.github.com/users/ably/gists{/gist_id}","starred_url":"https://api.github.com/users/ably/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ably/subscriptions","organizations_url":"https://api.github.com/users/ably/orgs","repos_url":"https://api.github.com/users/ably/repos","events_url":"https://api.github.com/users/ably/events{/privacy}","received_events_url":"https://api.github.com/users/ably/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ably/ably-js","description":"Ably Realtime Messaging Javascript library to connect from your browser or Node.js","fork":false,"url":"https://api.github.com/repos/ably/ably-js","forks_url":"https://api.github.com/repos/ably/ably-js/forks","keys_url":"https://api.github.com/repos/ably/ably-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ably/ably-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ably/ably-js/teams","hooks_url":"https://api.github.com/repos/ably/ably-js/hooks","issue_events_url":"https://api.github.com/repos/ably/ably-js/issues/events{/number}","events_url":"https://api.github.com/repos/ably/ably-js/events","assignees_url":"https://api.github.com/repos/ably/ably-js/assignees{/user}","branches_url":"https://api.github.com/repos/ably/ably-js/branches{/branch}","tags_url":"https://api.github.com/repos/ably/ably-js/tags","blobs_url":"https://api.github.com/repos/ably/ably-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ably/ably-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ably/ably-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ably/ably-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ably/ably-js/statuses/{sha}","languages_url":"https://api.github.com/repos/ably/ably-js/languages","stargazers_url":"https://api.github.com/repos/ably/ably-js/stargazers","contributors_url":"https://api.github.com/repos/ably/ably-js/contributors","subscribers_url":"https://api.github.com/repos/ably/ably-js/subscribers","subscription_url":"https://api.github.com/repos/ably/ably-js/subscription","commits_url":"https://api.github.com/repos/ably/ably-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ably/ably-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ably/ably-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ably/ably-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ably/ably-js/contents/{+path}","compare_url":"https://api.github.com/repos/ably/ably-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ably/ably-js/merges","archive_url":"https://api.github.com/repos/ably/ably-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ably/ably-js/downloads","issues_url":"https://api.github.com/repos/ably/ably-js/issues{/number}","pulls_url":"https://api.github.com/repos/ably/ably-js/pulls{/number}","milestones_url":"https://api.github.com/repos/ably/ably-js/milestones{/number}","notifications_url":"https://api.github.com/repos/ably/ably-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ably/ably-js/labels{/name}","releases_url":"https://api.github.com/repos/ably/ably-js/releases{/id}","created_at":"2012-11-13T19:41:13Z","updated_at":"2015-05-06T17:34:22Z","pushed_at":"2015-09-07T13:36:06Z","git_url":"git://github.com/ably/ably-js.git","ssh_url":"git@github.com:ably/ably-js.git","clone_url":"https://github.com/ably/ably-js.git","svn_url":"https://github.com/ably/ably-js","homepage":null,"size":11951,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":31,"forks":1,"open_issues":31,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ably/ably-js/pulls/122"},"html":{"href":"https://github.com/ably/ably-js/pull/122"},"issue":{"href":"https://api.github.com/repos/ably/ably-js/issues/122"},"comments":{"href":"https://api.github.com/repos/ably/ably-js/issues/122/comments"},"review_comments":{"href":"https://api.github.com/repos/ably/ably-js/pulls/122/comments"},"review_comment":{"href":"https://api.github.com/repos/ably/ably-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ably/ably-js/pulls/122/commits"},"statuses":{"href":"https://api.github.com/repos/ably/ably-js/statuses/76dee8722804357cd9905a3809c032518e088ed9"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":8,"deletions":2,"changed_files":1}}