kubetail-org / loadjs

A tiny async loader / dependency manager for modern browsers (899 bytes)
MIT License
2.58k stars 149 forks source link

Uncaught (in promise) LoadJS #51

Open Swapnilchavan18 opened 7 years ago

Swapnilchavan18 commented 7 years ago

loadjs(['https://test.com/js/fuploader.js'], 'photouploader');

while trying to load java-script file, I am getting error on single page react application.

amorey commented 7 years ago

What's the error you're getting? Also, which OS/Browser are you using?

Swapnilchavan18 commented 7 years ago

I am using chrome/windows 10, file loads on first load but when navigated back to same route where I am loading file, I get error "Uncaught (in promise) LoadJS" and js file does not load. I think it happens because file has to load from cache.

amorey commented 7 years ago

Can you share code to re-create the error on JSFiddle or CodePen? By "navigating back" do you mean hitting the back button?

Swapnilchavan18 commented 7 years ago

Its single page application , I mean without refresh.

amorey commented 7 years ago

Can you share code to reproduce the error? Does the fuploader.js file matter or are you getting the same error with other files?

I need more information to be able to debug the problem or recommend a work-around.

Swapnilchavan18 commented 7 years ago

Is there anything that I have to do in componentWillUnmount to load files when there is not a refresh between pages i.e for single page app

amorey commented 7 years ago

Based on your description I can't make any recommendations. If you can share some example code I can help you diagnose the problem. Can you paste the code into GitHub?

On Jul 19, 2017, at 12:32 PM, Swapnilchavan18 notifications@github.com wrote:

Is there anything that I have to do in componentWillUnmount to load files when there is not a refresh between pages i.e for single page app

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Swapnilchavan18 commented 7 years ago

ok Thanks . give me some time, I am using that in my personal project, I will create fiddle

SharlSherif commented 5 years ago

got the same exact error when loading js files on componentWillMount, it works the first time the component mounts after remounting again , it throws Uncaught (in promise) LoadJS --- asyncToGenerator.js:6 in the console. the asyncToGenerator.js :


  try {
    var info = gen[key](arg);
    var value = info.value;
  } catch (error) {
    reject(error); // error is thrown by this 
    return;
  }

  if (info.done) {
    resolve(value);
  } else {
    Promise.resolve(value).then(_next, _throw);
  }
}
amorey commented 5 years ago

@Sharl212 Thanks for letting us know. Can you share some example code that reproduces the problem?

amorey commented 5 years ago

@Sharl212 @Swapnilchavan18 Based on your description of the problem I think the issue might be that each call to componentWillMount() defines a LoadJS bundle but LoadJS throws an error when you try to reuse a previously used bundle name. Here's an example that highlights this condition: https://jsfiddle.net/muicss/2d9ryjfp/

In your code, are you defining a bundle name when you call loadjs()?