{"action":"created","issue":{"url":"https://api.github.com/repos/angular/zone.js/issues/377","repository_url":"https://api.github.com/repos/angular/zone.js","labels_url":"https://api.github.com/repos/angular/zone.js/issues/377/labels{/name}","comments_url":"https://api.github.com/repos/angular/zone.js/issues/377/comments","events_url":"https://api.github.com/repos/angular/zone.js/issues/377/events","html_url":"https://github.com/angular/zone.js/issues/377","id":165868365,"number":377,"title":"Synchronous XHR request through zonejs results in:  More tasks executed then were scheduled","user":{"login":"thelgevold","id":349548,"avatar_url":"https://avatars.githubusercontent.com/u/349548?v=3","gravatar_id":"","url":"https://api.github.com/users/thelgevold","html_url":"https://github.com/thelgevold","followers_url":"https://api.github.com/users/thelgevold/followers","following_url":"https://api.github.com/users/thelgevold/following{/other_user}","gists_url":"https://api.github.com/users/thelgevold/gists{/gist_id}","starred_url":"https://api.github.com/users/thelgevold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thelgevold/subscriptions","organizations_url":"https://api.github.com/users/thelgevold/orgs","repos_url":"https://api.github.com/users/thelgevold/repos","events_url":"https://api.github.com/users/thelgevold/events{/privacy}","received_events_url":"https://api.github.com/users/thelgevold/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-15T20:12:37Z","updated_at":"2016-07-15T20:42:55Z","closed_at":null,"body":"I am logging a bug report:\r\n\r\nThere seems to be a bug in the bookkeeping of `XMLHttpRequest` in zone.js.\r\n\r\nIf I  trigger a synchronous `XMLHttpRequest` when zonejs is loaded on the page I get the following error:\r\n`Error: More tasks executed then were scheduled.`\r\n\r\nThe error does not occur if the request is asynchronous.\r\n\r\nHere is a simple plunker with a repro: https://plnkr.co/edit/7Cn3JknfDIIHMIdqcuo0?p=preview\r\n\r\nI have not looked into this extensively, but the error occurs here:\r\n`next` is set to -1 which triggers the error condition.\r\n\r\n```\r\nZoneDelegate.prototype._updateTaskCount = function (type, count) {\r\n\t            var counts = this._taskCounts;\r\n\t            var prev = counts[type];\r\n\t            var next = counts[type] = prev + count;\r\n\t            if (next < 0) {\r\n\t                throw new Error('More tasks executed then were scheduled.');\r\n\t            }\r\n\t            if (prev == 0 || next == 0) {\r\n\t                var isEmpty = {\r\n\t                    microTask: counts.microTask > 0,\r\n\t                    macroTask: counts.macroTask > 0,\r\n\t                    eventTask: counts.eventTask > 0,\r\n\t                    change: type\r\n\t                };\r\n\t                try {\r\n\t                    this.hasTask(this.zone, isEmpty);\r\n\t                }\r\n\t                finally {\r\n\t                    if (this._parentDelegate) {\r\n\t                        this._parentDelegate._updateTaskCount(type, count);\r\n\t                    }\r\n\t                }\r\n\t            }\r\n\t        };\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/angular/zone.js/issues/comments/233064837","html_url":"https://github.com/angular/zone.js/issues/377#issuecomment-233064837","issue_url":"https://api.github.com/repos/angular/zone.js/issues/377","id":233064837,"user":{"login":"thelgevold","id":349548,"avatar_url":"https://avatars.githubusercontent.com/u/349548?v=3","gravatar_id":"","url":"https://api.github.com/users/thelgevold","html_url":"https://github.com/thelgevold","followers_url":"https://api.github.com/users/thelgevold/followers","following_url":"https://api.github.com/users/thelgevold/following{/other_user}","gists_url":"https://api.github.com/users/thelgevold/gists{/gist_id}","starred_url":"https://api.github.com/users/thelgevold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thelgevold/subscriptions","organizations_url":"https://api.github.com/users/thelgevold/orgs","repos_url":"https://api.github.com/users/thelgevold/repos","events_url":"https://api.github.com/users/thelgevold/events{/privacy}","received_events_url":"https://api.github.com/users/thelgevold/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T20:42:55Z","updated_at":"2016-07-15T20:42:55Z","body":"I agree that sync xhr requests are discouraged, but I think a warning is more appropriate than an error in this scenario."}}
{"actor":{"display_login":"thelgevold"}}