Script.load fails silently


#1

I use the Script.load function in some of the scripts I’ve made but now they seem to fail.

It still is listed in the currentAPI.js results and does not generate any errors that I’ve found in the log.

What I used to test it with looks something like this:

if (1) {
 	Script.load("https://s3-us-west-1.amazonaws.com/someScript.js"); 
	print("script loaded");
} 
else {
	print("script not loaded");
}

Looking at the log file I find something like this:

[02/03 12:50:07] [DEBUG] Done downloading script at: “https://s3-us-west-1.amazonaws.com/hifitests/scriptloadtest-05d.js
[02/03 12:50:07] [DEBUG] script:print()<< script loaded

Which looks fine except that the script did not load, there is no notice in the log of it starting to load or finish or fail to load and it does not show up in running scripts.

In the example above, the script url does not really exist, so I would at least expect it to give an error notice in the log and even when I put in script urls that are correct and used to work a week or so ago, it still fails with no message.

Any ideas anyone?


#2

Hmm, you should be seeing an error in the log. I tried using the js console to load your script and got this:

[02/03 13:41:29] [WARNING] Error loading script from URL  QUrl("https://s3-us-west-1.amazonaws.com/someScript.js")
[02/03 13:41:29] [DEBUG] ERROR Loading file: "https://s3-us-west-1.amazonaws.com/someScript.js" line: 231
[02/03 13:41:29] [DEBUG] Application::loadScript(), script failed to load...

This was using latest on Windows 10. Which version and OS are you on?

Ryan


#3

Thanks @huffman for the reply, although it didn’t really help much, it did end up leading me in the right direction.

I should have been more clear in my post. The script that was taken from is an entity script. And yes it does fail for me too when run from the console.

But thanks to Kevin, I’ve tracked down what the problem was and they work again now. I was not aware that Script.load was changed and you have to use scriptDiscoveryService now in entities. It still seems odd to me that it did not generate an error in the interface log but maybe it did in the domain log and I just did not see it the one time I looked there.

I would feel dumb for posting about the “bug” but, they did work correctly for months and without searching through all the version change docs (if this was even documented), I had no way of knowing about the change.