Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

WebSocket patch on Android causes infinite recursion #233

Closed
tlancina opened this issue Jan 25, 2016 · 1 comment
Closed

WebSocket patch on Android causes infinite recursion #233

tlancina opened this issue Jan 25, 2016 · 1 comment

Comments

@tlancina
Copy link
Contributor

It looks like when canPatchViaPropertyDescriptor() is false, WebSocket's addEventListener is patched again: property-descriptor.ts#L29, websocket.ts#L6 after already being patched as part of browser.ts#L27.

Setting any of the WebSocket event handlers then causes infinite recursion as the "original" handler that gets called by the second patch is the already patched one from when the EventTarget handlers were patched: utils.ts#L86

You can reproduce minimally on desktop Chrome by breaking on property-descriptor.ts#L14 and having it return false: http://plnkr.co/edit/XF2mZMA6XBHuApVz6BJ4?p=preview (line 736 for me).

We had reports of this happening on Android 4.4 and 5.1, but I've only been able to reproduce on device with 4.4, though in theory it would happen for any devices where patching via property descriptors is unavailable.

Happy to submit a PR, but there is a lot going on between various different browsers and I'm not entirely sure what the best solution that wouldn't break other things is.

@manekinekko
Copy link

thanks @tlancina for this patch 👍

SurendraShukla pushed a commit to SurendraShukla/Javascript that referenced this issue Apr 11, 2017
closes #235

On older versions of Chrome, patching via property descriptors isn't
available, but unlike Safari, window.EventTarget exists and is already
patched, so the EventTarget methods on WebSocket.prototype don't need to
be patched again.

Closes angular/zone.js#233.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants