New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macro Tasks left running after failed http requests with Unknown Error, preventing protractor from completing tests #38795
Comments
Confirmed and identified #37367 to be the cause (reverting that change fixes the issue). |
@JiaLiPassion could you have a look at zone.js's XHR patching to see if this is something that can be addressed from within zone.js, without needing to revert #37367? |
@JoostK , sure, I just checked this one, I think this can be handled inside |
Close angular#38795 in XMLHttpRequest patch, when get `readystatechange` event, zone.js try to invoke `load` event listener first, then call `invokeTask` to finish the `XMLHttpRequest::send` macroTask, but if the request failed because the server can not be reached, the `load` event listener will not be invoked, so the `invokeTask` of the `XMLHttpRequest::send` will not be triggered either, so we will have a non finished macroTask there which will make the Zone not stable, also memory leak. So in this PR, if the `XMLHttpRequest.status = 0` when we get the `readystatechange` event, that means something wents wrong before we reached the server, we need to invoke the task to finish the macroTask.
Close angular#38795 in the XMLHttpRequest patch, when get `readystatechange` event, zone.js try to invoke `load` event listener first, then call `invokeTask` to finish the `XMLHttpRequest::send` macroTask, but if the request failed because the server can not be reached, the `load` event listener will not be invoked, so the `invokeTask` of the `XMLHttpRequest::send` will not be triggered either, so we will have a non finished macroTask there which will make the Zone not stable, also memory leak. So in this PR, if the `XMLHttpRequest.status = 0` when we get the `readystatechange` event, that means something wents wrong before we reached the server, we need to invoke the task to finish the macroTask.
…rs (#38836) Close #38795 in the XMLHttpRequest patch, when get `readystatechange` event, zone.js try to invoke `load` event listener first, then call `invokeTask` to finish the `XMLHttpRequest::send` macroTask, but if the request failed because the server can not be reached, the `load` event listener will not be invoked, so the `invokeTask` of the `XMLHttpRequest::send` will not be triggered either, so we will have a non finished macroTask there which will make the Zone not stable, also memory leak. So in this PR, if the `XMLHttpRequest.status = 0` when we get the `readystatechange` event, that means something wents wrong before we reached the server, we need to invoke the task to finish the macroTask. PR Close #38836
Hi @JiaLiPassion, Thanks for looking into this issue I was seeing. I have tried updating my minimal reproduction repo to 10.1.4 to see that your commit fixes the issues, although I am still seeing macroTasks left running after requests to non-existent urls. I believe the fix should be in the release, am I mistaken?
https://github.com/wfairclough/AngularHttpMacroTaskMinimalReproduction |
@wfairclough Could you try with zone.js 0.11.2? It's released separately from the main framework; the changelog can be found here. |
@JoostK Thanks for pointing that out. Doesn't look like 0.11.2 has been released to npm as of now, I will try it once it has been published. |
@wfairclough Oh, I didn't realize that. But now that you mention it, I remembered there's #39094 for that. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
@angular/common/http
Is this a regression?
Yes.
Worked in @angular/common@9.1.12
Description
A macroTask is left running when certain http errors occur and this prevents protractor for completing since there are tasks left running in the ngZone.
🔬 Minimal Reproduction
https://github.com/wfairclough/AngularHttpMacroTaskMinimalReproduction
Run
npm install
Run with
npx ng serve
Open Chrome Browser to
http://localhost:4200
Reproduce Bug
🔥 Exception or Error
No macroTasks should be left running after this failed http request.
🌍 Your Environment
Angular Version:
Anything else relevant?
Error occurs in both browsers I tested with Chrome and Firefox.
The text was updated successfully, but these errors were encountered: