loadjs icon indicating copy to clipboard operation
loadjs copied to clipboard

Uncaught (in promise) LoadJS

Open Swapnilchavan18 opened this issue 7 years ago • 11 comments

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

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

Swapnilchavan18 avatar Jul 19 '17 15:07 Swapnilchavan18

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

amorey avatar Jul 19 '17 15:07 amorey

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.

Swapnilchavan18 avatar Jul 19 '17 15:07 Swapnilchavan18

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

amorey avatar Jul 19 '17 15:07 amorey

Its single page application , I mean without refresh.

Swapnilchavan18 avatar Jul 19 '17 15:07 Swapnilchavan18

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.

amorey avatar Jul 19 '17 15:07 amorey

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

Swapnilchavan18 avatar Jul 19 '17 16:07 Swapnilchavan18

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 [email protected] 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.

amorey avatar Jul 19 '17 16:07 amorey

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

Swapnilchavan18 avatar Jul 19 '17 17:07 Swapnilchavan18

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);
  }
}

SharlSherif avatar Mar 17 '19 16:03 SharlSherif

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

amorey avatar Mar 17 '19 18:03 amorey

@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()?

amorey avatar Mar 18 '19 12:03 amorey