pretenderjs / pretender

A mock server library with a nice routing DSL
MIT License
1.26k stars 158 forks source link

Passthrough not working with axios 0.21.2+ #354

Open DrewCerny opened 2 years ago

DrewCerny commented 2 years ago

Axios has made a change in version 0.21.2 that no longer adds a handler for onreadystatechange if the browser supports onloadend. Since the passthrough logic does not watch for the loadend event it does not pass it through. The result is that axios requests that should passthrough just hang.

vsergiu93 commented 2 years ago

Any news on this one? Is there any way we can get the proposed fix merged?

murashki commented 2 years ago

This bug could be fixed with this code. Note! You should require this code after const server = new Pretender();.

    const server = new Pretender();

    // FIX -->
    const NativeXMLHttpRequest = window.XMLHttpRequest;

    window.XMLHttpRequest = function XMLHttpRequest() {
      const request = new NativeXMLHttpRequest(arguments);
      delete request.onloadend;
      return request;
    };
    // <-- FIX
lxulf commented 1 year ago

Would be awesome to have this fixed! :)

canyavall commented 1 year ago

agree, some way we can push for it?