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

Does not work with ES6-Promise polyfill #43

Open
cheresier opened this issue Apr 10, 2019 · 6 comments
Open

Does not work with ES6-Promise polyfill #43

cheresier opened this issue Apr 10, 2019 · 6 comments
Assignees
Milestone

Comments

@cheresier
Copy link

cheresier commented Apr 10, 2019

I am trying to use this plugin in IE11 (as part of developing a non-transpiled Excel add-in, which run in an IE11 frame when used with Office desktop), so I have to rely on a polyfill to make promises work. While no error is thrown, Vue eventually times out trying to load the component. Wondering if there is a simple fix for that and looking forward to being able to use this seemingly awesome plugin.

@edgardleal
Copy link
Owner

edgardleal commented Apr 11, 2019

Hi @cheresier , this looks to be an interesting project.
Did you tried to increase the value of waitSeconds in requirejs setup ?
https://requirejs.org/docs/api.html#config-waitSeconds

@cheresier
Copy link
Author

Thank you for your response! Yes, I even set it to 0 to disable timeout altogether.

@edgardleal edgardleal self-assigned this Apr 11, 2019
@edgardleal
Copy link
Owner

Hi @cheresier , can you post an example of code ?

@edgardleal edgardleal added this to the 1.1.4 milestone Apr 22, 2019
@cheresier
Copy link
Author

Sure! The quickest way to reproduce is to pretty much use your code from the https://github.com/edgardleal/require-vuejs#source-code-example page, but with
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
added above the require.js reference.

The polyfill above results in this error:

SCRIPT5022: Load timeout for modules: vue!component_unnormalized2,vue!component
http://requirejs.org/docs/errors.html#timeout

I also tried using another polyfill:
https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.3/polyfill.js

In this case the error above is preceded with another one:
2019-04-22 17_31_35-Require Vue - Internet Explorer

All this obviously applies to IE11. I will also add that the polyfill works correctly for other modern scripts I am using in this project (like vuetify)

@racksen
Copy link

racksen commented Aug 23, 2019

After long struggling, I used the axios to replace the loadRemote(url) function. It worked in IE11.

@FerdinandPiette
Copy link

FerdinandPiette commented Feb 28, 2020

Hi,
I had the same problem on ie11.

It is due to the definition of xhttp.timeout that should be placed after xhttp.open
It is explain in MDN : https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout
This solve the problem.

return new Promise(function(resolve, reject) {
    var xhttp = new XMLHttpRequest();
    /* // IE11 : dont like timeout here
    xhttp.timeout = (
        (config.waitSeconds || config.timeout) || 3
    ) * 1000;//*/
    xhttp.onreadystatechange = function() {
        if (xhttp.readyState === 4
      && xhttp.status < 400) {
            var result = parse(xhttp.responseText);
            callback(result);
            resolve(result);
        }
    };
    xhttp.ontimeout = function() {
        var error = new Error("Timeout loading: " + path);
        callback({}, error);
        reject(error);
        throw error;
    };
    xhttp.open("GET", path, true);
    //* // Fix ie11 : timeout should be place here
    xhttp.timeout = (
        (config.waitSeconds || config.timeout) || 3
    ) * 1000;//*/
    xhttp.send();
});

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

No branches or pull requests

4 participants