{"action":"created","issue":{"url":"https://api.github.com/repos/angular/zone.js/issues/657","repository_url":"https://api.github.com/repos/angular/zone.js","labels_url":"https://api.github.com/repos/angular/zone.js/issues/657/labels{/name}","comments_url":"https://api.github.com/repos/angular/zone.js/issues/657/comments","events_url":"https://api.github.com/repos/angular/zone.js/issues/657/events","html_url":"https://github.com/angular/zone.js/issues/657","id":211514280,"node_id":"MDU6SXNzdWUyMTE1MTQyODA=","number":657,"title":"Error caused by patched XMLHttpRequest","user":{"login":"devoto13","id":823594,"node_id":"MDQ6VXNlcjgyMzU5NA==","avatar_url":"https://avatars1.githubusercontent.com/u/823594?v=4","gravatar_id":"","url":"https://api.github.com/users/devoto13","html_url":"https://github.com/devoto13","followers_url":"https://api.github.com/users/devoto13/followers","following_url":"https://api.github.com/users/devoto13/following{/other_user}","gists_url":"https://api.github.com/users/devoto13/gists{/gist_id}","starred_url":"https://api.github.com/users/devoto13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devoto13/subscriptions","organizations_url":"https://api.github.com/users/devoto13/orgs","repos_url":"https://api.github.com/users/devoto13/repos","events_url":"https://api.github.com/users/devoto13/events{/privacy}","received_events_url":"https://api.github.com/users/devoto13/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":36,"created_at":"2017-03-02T20:54:23Z","updated_at":"2018-07-08T16:34:20Z","closed_at":"2017-03-07T00:33:57Z","author_association":"NONE","body":"We're using Angular with Zone.js 0.7.7 in the WebView in our mobile application. The problem is that quite often we get [following error](https://github.com/angular/zone.js/blob/v0.7.7/dist/zone.js#L445-L447):\r\n\r\n    Error: macroTask 'XMLHttpRequest.send': can not transition to 'running', expecting state 'scheduled', was 'notScheduled'.\r\n\r\nReal application is complex, but we managed to come up with a minimal reproduction. Basically it's mobile application, which does following sequence of actions in the infinite loop with 1s delay:\r\n\r\n1. Native code calls function in the WebView using `stringByEvaluatingJavaScript` function.\r\n2. [This function](https://github.com/devoto13/zone-error-repro/blob/master/WebViewTest/Resources/index.html#L39-L55) sends HTTP request using `XMLHttpRequest`.\r\n\r\nOnce I scroll page up/down for 2-3 seconds, mentioned error occurs.\r\n\r\n- Error doesn't happen, when there is no scrolling done. So it seems to be related to some events happening in browser.\r\n- Error doesn't happen if we call function using `setInterval()` inside WebView instead of calling from native code. So it seems to be related to how WebView executes code from outside.\r\n- Error doesn't happen, when I add small synchronous computation in the `ZoneTask._transitionTo()` (O.o). Tried to log unique IDs for every task using approach described [here](http://stackoverflow.com/a/1997811/1377864). See [commented code](https://github.com/devoto13/zone-error-repro/blob/master/WebViewTest/Resources/zone.js#L437). This one looks like a complete magic to me.\r\n\r\nI understand that this is still pretty complex reproduction, but I have no idea how to reduce it further. Do you have any ideas why it can happen and how can I debug it further? I can also provide any extra details if needed.\r\n\r\nProject can be found [here](https://github.com/devoto13/zone-error-repro). To reproduce you need to open project with XCode, run it on device, connect with [Safari remote debugging](http://moduscreate.com/enable-remote-web-inspector-in-ios-6/) and scroll up/down for 2-3 seconds. Error is usually reproducible after couple of seconds of scrolling."},"comment":{"url":"https://api.github.com/repos/angular/zone.js/issues/comments/403299653","html_url":"https://github.com/angular/zone.js/issues/657#issuecomment-403299653","issue_url":"https://api.github.com/repos/angular/zone.js/issues/657","id":403299653,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzI5OTY1Mw==","user":{"login":"herkulano","id":125300,"node_id":"MDQ6VXNlcjEyNTMwMA==","avatar_url":"https://avatars2.githubusercontent.com/u/125300?v=4","gravatar_id":"","url":"https://api.github.com/users/herkulano","html_url":"https://github.com/herkulano","followers_url":"https://api.github.com/users/herkulano/followers","following_url":"https://api.github.com/users/herkulano/following{/other_user}","gists_url":"https://api.github.com/users/herkulano/gists{/gist_id}","starred_url":"https://api.github.com/users/herkulano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/herkulano/subscriptions","organizations_url":"https://api.github.com/users/herkulano/orgs","repos_url":"https://api.github.com/users/herkulano/repos","events_url":"https://api.github.com/users/herkulano/events{/privacy}","received_events_url":"https://api.github.com/users/herkulano/received_events","type":"User","site_admin":false},"created_at":"2018-07-08T16:34:20Z","updated_at":"2018-07-08T16:34:20Z","author_association":"NONE","body":"@JiaLiPassion I'm also getting a similar error using Cypress `cy.type('something)` command on a form. In my case, your workaround doesn't work.\r\n\r\n```\r\nmacroTask 'setTimeout': can not transition to 'running', expecting state 'scheduled', was 'notScheduled'.\r\n```"}}
{"actor":{"display_login":"herkulano"}}