-
Notifications
You must be signed in to change notification settings - Fork 407
Ensure that EventTarget is patched prior to legacy property descriptor patch #1214
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it |
@jwKimo, could you describe which |
@JiaLiPassion This was discovered on internal Google application running on an LG WebOS 3.0 SmartTV device. The error is that XMLHttpRequests fail to process due to a type error occurring due to attempting to make an call on undefined for "__zone_symbol__addEventListener" at https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts#L166 This is due to patchClass of "XMLHttpRequest" (https://github.com/angular/zone.js/blob/master/lib/browser/property-descriptor-legacy.ts#L25) taking place before patching of event target(This was not the case in v0.8.21). Which does does take place in event-target-legacy as it returns if EventTarget is defined: https://github.com/angular/zone.js/blob/master/lib/browser/event-target-legacy.ts#L26 |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
1 similar comment
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@jwKimo, thanks, so this error occurs before https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts#L78 is called, is that right? |
@JiaLiPassion No. The error occurs when attempting to create and send an XMLHttpRequest. The send triggers scheduleTask(https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts#L117) which will attempt to call undefined variable (https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts#L166) |
@jwKimo, Sorry for the late reply, I know the error is because https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts#L166. So the current situation is,
And the load order is
And the error is After your fix, the problem is gone, is that right? Sorry for the long text, I just want to make sure I understand the whole situation, Thank you! |
Ah yes should have elaborated on that part.
|
@jwKimo, thank you for the detail information, I understand the reason now, so the underlying reason is |
Thanks! I don't have write access so someone else would need to merge the pull request. |
If the event that EventTarget is defined on a device that also does not support patch via property descriptor, the result is that the XMLHttpRequest class would be patched prior to the event target being patched (due to returning in event-target-legacy if EventTarget is defined). This results in the wrapper that replaces XMLHttpRequest missing the patched listener fields. E.g. __zone_symbol__addEventListener and __zone_symbol__removeEventListener
event-target-legacy.
The result is that for any attempted http requests, a type error occurs in scheduleTask in browse.ts -> patchXhr, due to attempting call to non-existent __zone_symbol__addEventListener and __zone_symbol__removeEventListener, causing the requests to fail.
Ensuring that patching of event target for legacy path takes place before legacy property descriptor patch eliminates this problem.