{"action":"closed","number":397,"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397","id":49642110,"html_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/397","diff_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/397.diff","patch_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/397.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/397","number":397,"state":"closed","locked":false,"title":"Bug 1220406 - [email] Possible sync wedging when two syncs overlap r=asuth","user":{"login":"jrburke","id":73359,"avatar_url":"https://avatars.githubusercontent.com/u/73359?v=3","gravatar_id":"","url":"https://api.github.com/users/jrburke","html_url":"https://github.com/jrburke","followers_url":"https://api.github.com/users/jrburke/followers","following_url":"https://api.github.com/users/jrburke/following{/other_user}","gists_url":"https://api.github.com/users/jrburke/gists{/gist_id}","starred_url":"https://api.github.com/users/jrburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrburke/subscriptions","organizations_url":"https://api.github.com/users/jrburke/orgs","repos_url":"https://api.github.com/users/jrburke/repos","events_url":"https://api.github.com/users/jrburke/events{/privacy}","received_events_url":"https://api.github.com/users/jrburke/received_events","type":"User","site_admin":false},"body":"There are two commits in here, but I will flatten before I merge. The first one was just a removal of the _killSlices/_activeSlices code, which is the core of the bug. However, looking more into the properties on the CronSync instances, the following properties also seemed subject to multiple onAlarm calls in quick succession:\r\n\r\n* this._syncAccountsDone = true;\r\n* this._onSyncDone = null;\r\n* this._synced = [];\r\n\r\nSince these are set up per-onAlarm call, the state could get weird.\r\n\r\nThere was also _completedEnsureSync, which is something that really only needs to be done once if there are multiple, quick onAlarm calls.\r\n\r\nNow that we can reliably use promises, I went with using a promise for the ensureSync work, which simplified the code (no more _checkSyncDone), and by switching syncAccount to return a Promise, it meant getting rid of the done() tracking of a syncMax and syncCount.\r\n\r\nsyncAccount did not change that much, it is mostly an indentation, so using ?w=1 when looking on github at the diff may help remove some of the change churn.\r\n\r\nThese changes made it possible then to get rid of the instance variables above because the information could just be tracked in the onAlarm function and the closures due to the promise usage.\r\n\r\nI then took the chance to convert to arrow functions, and then to change the define() signature to the simplified CJS wrapper.\r\n\r\nI tested in the gaia app and waited for the sync overlap, and it completed fine. The neat thing is that the two alarms seemed to gradually synchronize/overlap for a very long period of time (until I finished testing, which was 5 more syncs), so I think that is nice from a consolidation of work. Just one ensureSync pass was needed in that scenario too.\r\n","created_at":"2015-11-04T02:44:42Z","updated_at":"2015-11-04T05:27:32Z","closed_at":"2015-11-04T05:27:32Z","merged_at":"2015-11-04T05:27:32Z","merge_commit_sha":"f018fe0cc0e3ce61c7afaa8bcff6a7fb0e14b870","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/397/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/statuses/05864a5c4dd30205aa7622d08f382403feea5e5b","head":{"label":"jrburke:bug1220406-email-bg-sync-wedge","ref":"bug1220406-email-bg-sync-wedge","sha":"05864a5c4dd30205aa7622d08f382403feea5e5b","user":{"login":"jrburke","id":73359,"avatar_url":"https://avatars.githubusercontent.com/u/73359?v=3","gravatar_id":"","url":"https://api.github.com/users/jrburke","html_url":"https://github.com/jrburke","followers_url":"https://api.github.com/users/jrburke/followers","following_url":"https://api.github.com/users/jrburke/following{/other_user}","gists_url":"https://api.github.com/users/jrburke/gists{/gist_id}","starred_url":"https://api.github.com/users/jrburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrburke/subscriptions","organizations_url":"https://api.github.com/users/jrburke/orgs","repos_url":"https://api.github.com/users/jrburke/repos","events_url":"https://api.github.com/users/jrburke/events{/privacy}","received_events_url":"https://api.github.com/users/jrburke/received_events","type":"User","site_admin":false},"repo":{"id":6818283,"name":"gaia-email-libs-and-more","full_name":"jrburke/gaia-email-libs-and-more","owner":{"login":"jrburke","id":73359,"avatar_url":"https://avatars.githubusercontent.com/u/73359?v=3","gravatar_id":"","url":"https://api.github.com/users/jrburke","html_url":"https://github.com/jrburke","followers_url":"https://api.github.com/users/jrburke/followers","following_url":"https://api.github.com/users/jrburke/following{/other_user}","gists_url":"https://api.github.com/users/jrburke/gists{/gist_id}","starred_url":"https://api.github.com/users/jrburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrburke/subscriptions","organizations_url":"https://api.github.com/users/jrburke/orgs","repos_url":"https://api.github.com/users/jrburke/repos","events_url":"https://api.github.com/users/jrburke/events{/privacy}","received_events_url":"https://api.github.com/users/jrburke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jrburke/gaia-email-libs-and-more","description":"","fork":true,"url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more","forks_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/forks","keys_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/teams","hooks_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/hooks","issue_events_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/issues/events{/number}","events_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/events","assignees_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/assignees{/user}","branches_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/branches{/branch}","tags_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/tags","blobs_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/git/refs{/sha}","trees_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/statuses/{sha}","languages_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/languages","stargazers_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/stargazers","contributors_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/contributors","subscribers_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/subscribers","subscription_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/subscription","commits_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/commits{/sha}","git_commits_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/git/commits{/sha}","comments_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/comments{/number}","issue_comment_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/issues/comments{/number}","contents_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/contents/{+path}","compare_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/merges","archive_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/downloads","issues_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/issues{/number}","pulls_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/pulls{/number}","milestones_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/milestones{/number}","notifications_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/labels{/name}","releases_url":"https://api.github.com/repos/jrburke/gaia-email-libs-and-more/releases{/id}","created_at":"2012-11-22T19:53:27Z","updated_at":"2015-04-02T21:14:32Z","pushed_at":"2015-11-04T04:27:36Z","git_url":"git://github.com/jrburke/gaia-email-libs-and-more.git","ssh_url":"git@github.com:jrburke/gaia-email-libs-and-more.git","clone_url":"https://github.com/jrburke/gaia-email-libs-and-more.git","svn_url":"https://github.com/jrburke/gaia-email-libs-and-more","homepage":"","size":12067,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"49a31b022af5811a6d985e3f62d5c7a2f1307221","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":3890726,"name":"gaia-email-libs-and-more","full_name":"mozilla-b2g/gaia-email-libs-and-more","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more","description":"E-mail libraries for the Firefox OS Gaia E-mail client","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/releases{/id}","created_at":"2012-04-01T06:21:02Z","updated_at":"2015-10-08T12:33:49Z","pushed_at":"2015-11-04T05:27:32Z","git_url":"git://github.com/mozilla-b2g/gaia-email-libs-and-more.git","ssh_url":"git@github.com:mozilla-b2g/gaia-email-libs-and-more.git","clone_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more.git","svn_url":"https://github.com/mozilla-b2g/gaia-email-libs-and-more","homepage":"https://wiki.mozilla.org/Gaia/Email","size":17457,"stargazers_count":35,"watchers_count":35,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":6,"forks":36,"open_issues":6,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397"},"html":{"href":"https://github.com/mozilla-b2g/gaia-email-libs-and-more/pull/397"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/397"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/issues/397/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/pulls/397/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia-email-libs-and-more/statuses/05864a5c4dd30205aa7622d08f382403feea5e5b"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"jrburke","id":73359,"avatar_url":"https://avatars.githubusercontent.com/u/73359?v=3","gravatar_id":"","url":"https://api.github.com/users/jrburke","html_url":"https://github.com/jrburke","followers_url":"https://api.github.com/users/jrburke/followers","following_url":"https://api.github.com/users/jrburke/following{/other_user}","gists_url":"https://api.github.com/users/jrburke/gists{/gist_id}","starred_url":"https://api.github.com/users/jrburke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrburke/subscriptions","organizations_url":"https://api.github.com/users/jrburke/orgs","repos_url":"https://api.github.com/users/jrburke/repos","events_url":"https://api.github.com/users/jrburke/events{/privacy}","received_events_url":"https://api.github.com/users/jrburke/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":1,"additions":181,"deletions":251,"changed_files":2}}