No errors thrown/displayed when in a deferred callback

谁说我不能喝 提交于 2019-12-24 17:46:14

问题


We're building a project with RequireJS and Node, and reusing modules both server and client side. It's going pretty good so far (some small kinks to work out).

An issue seems to be that errors inside a deferred callback don't ever get displayed in the node console (or in any other way for that matter). Making it very hard to debug.

asdasdasd(); // Throws error, function is undefined, as intended
this.loadOrganization(organization_key, true).then(function(org) {
    asdasdasd(); // No error anywhere, script just stops executing
});

loadOrganization returns a deferred object, and the callback gets called fine - However no error messages pertaining to undefined are displayed (general syntax errors are reported by node when evaluating the module).

We bootstrap content for the browser on the serverside using jsdom with jquery. And then pass the jquery from jsdon to most methods - So the deferred object used for the loadOrganization is the one from jQuery via jsdom. Changing the deferred used to one from npm installed jquery however makes no difference.

Any suggestions would be helpful, its pretty hard to debug when there are no errors printed.


回答1:


Figured it out, was a wild try/catch statement in our Backbone.Sync implementation on the serverside. Which meant that anything going through the API (which is pretty much anything) was being caught by a try/catch that passed the error on to the Backbone.Sync error callback, and was never heard from again.

So moral of the story; Look through your code for Try/Catches if no errors are outputted.



来源:https://stackoverflow.com/questions/10572821/no-errors-thrown-displayed-when-in-a-deferred-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!