Skip to content
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

Breaks class properties of XmlHTTPRequest #261

Open
ef4 opened this issue Oct 13, 2015 · 13 comments
Open

Breaks class properties of XmlHTTPRequest #261

ef4 opened this issue Oct 13, 2015 · 13 comments

Comments

@ef4
Copy link

ef4 commented Oct 13, 2015

When this library extends XMLHttpRequest here:

https://github.com/HubSpot/pace/blob/b202561ac0d5721a5df8d48dbf94f237c3d44405/pace.coffee#L343-L348

It doesn't bring along the properties of the XMLHttpRequest object itself. For example, XMLHttpRequest.DONE is supposed to be a constant, but after extension it's not.

@jesjobom
Copy link

jesjobom commented Jan 3, 2016

Would that be the cause of
new XMLHttpRequest() instanceof XMLHttpRequest; //false
?

I had some problems with it...

@ef4
Copy link
Author

ef4 commented Jan 4, 2016

Yes, the extension strategy breaks that too.

@ghost
Copy link

ghost commented Jan 14, 2016

I'm not sure this is the same issue, but I was working on a XMLHttpRequest methods reload and found that prototype is broken
console.log(XMLHttpRequest.prototype.send); // undefined

This may lead to incompatibility with custom code or other plugins, which rewrites the XMLHttpRequest prototype. This can be fixed by adding:
XMLHttpRequest.prototype = Object.getPrototypeOf(new XMLHttpRequest);
after pace.js was initialized:
console.log(XMLHttpRequest.prototype.send); // function send() { [native code] }

On the OpenToke custom service mentioned that this issue can be fixed by adding
to.prototype = Object.getPrototypeOf(new from); before 375 line in the pace.js file.
See more: https://forums.tokbox.com/bugs/opentok-conflicts-with-pace-js-t46935

@nitinsurana
Copy link

Is this fixed yet ?
Same as @jesjobom new instances returns false.

@khoan
Copy link

khoan commented Nov 23, 2016

bump

@ValentinFunk
Copy link

Really bad issue, this breaks all sorts of scripts in subtle and frustrating ways.

@andreabisello
Copy link

andreabisello commented Mar 22, 2017

The use of this library hangs implementation based on XMLHttpRequests .
My customer use this library in their website and this will broke my project.
When it will be fixed?
thanks.

@Tomm96
Copy link

Tomm96 commented Jul 7, 2017

Bump. It really conflicts with Symfony toolbar. No AJAX calls in the web profiler.

@1antares1
Copy link

1antares1 commented Jul 13, 2017

Thanks @ecolotko
Effectively! That instruction before line 375, has worked for me.
appInsight from Azure doesn't track why .send function() is replaced.

In case of using the version: pace.min.js, you only have to search for the statement:

:a[d]=b.prototype[d]:void 0)}catch(f){c=f}

Replace by:

:a[d]=b.prototype[d]:void 0)}catch(f){c=f}a.prototype = Object.getPrototypeOf(new b);

For those still working with bower, I suggest copying: pace.min.js (modified) and copying to an external route, and use: override.

Example:

     Pace
       "Main": [
         "../../content/scripts/custom/pace.min.js",
       ]
     }

Best regards.

@pjehan
Copy link

pjehan commented Sep 16, 2017

Thanks @1antares1

Update for version 1.0.2, search for:
a[d]=b.prototype[d]):e.push(void 0)}catch(f){c=f}

Fixed the conflict with Symfony Profiler.

@lastzero
Copy link

Any reason why this wasn't fixed so far? Do you need a pull request?

@a2intl
Copy link
Contributor

a2intl commented Nov 4, 2020

I think I tracked this down to the key not being loop-localized in extendNative here: https://github.com/HubSpot/pace/blob/master/pace.coffee#L296 , so all the XMLHttpRequests property values end up as the value of the last-property-enumerated. I'll submit a PR, but it doesn't seem like there's anyone merging them for the last couple years.

FranDias added a commit that referenced this issue Nov 4, 2020
fix issue #261 by localizing key per loop in extendNative
a2intl added a commit to a2intl/pace that referenced this issue Nov 5, 2020
@dragonbane0
Copy link

dragonbane0 commented Dec 1, 2020

CookiePro was also affected by this, which #504 successfully fixed. Good job! Maybe a new publish to NPM could be considered, since many use it from there to this day and the versions up there are very outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests