[BUG] Inside a callback from onLoad, there is no error log

Try the following code:

onLoad: function ()
{
    cc.loader.loadRes("datafile", function(error, data) {
        console.log("before");
        undefinedVariable.property;
        console.log("after");
    });
},

If assets/resources/datafile.json does not exist (that is, it’s a loading failure), the console output, either in the browser or the simulator, will be:

before
ReferenceError: undefinedVariable is not defined

If assets/resources/datafile.json exists, the console output, either in the browser or the simulator, will be:

before

So if it loads the file, Cocos will suppress all errors inside that completeCallback, failing silently.

If loading failed, your callback will be run asynchronous, which make the exception thrown outside the Creator’s call stacks. So if there’s no global onError handler, your exception will be swallowed.
If it loads the file successfully, loadRes should also ensure the callback run asynchronous, but due to some potential bug, sometimes it will call synchronous. So the ‘zalgo’ released…

This is a bug, thanks for the feedback.