ember.js:如何根据资产/供应商* .js进行调试 [英] ember.js: how to debug based on assets/vendor-*.js

查看:46
本文介绍了ember.js:如何根据资产/供应商* .js进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更多是一个普遍的问题,但是我想其他人也遇到了这个问题-例如,参见以下SO问题: Ember.js:如何分析vendor.js中的错误

This is more of a general question, but I imagine others have encountered this problem as well -- see for instance this SO question: Ember.js: how to analyze error in vendor.js

我正在开发一个更大的基于Ember的应用程序,在该应用程序中,如果发生错误,有时会得到相当隐秘的堆栈跟踪,类似于以下示例:

I am working on a larger Ember-based application, where, if errors occur, I sometimes get rather cryptic stack traces, similar to this sample:

TypeError: e.indexOf is not a function
at e.func (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:13:6039)
at e.get (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:11:29357)
at Object.o [as isPath] (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:13:5640)
at Object.u [as set] (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:13:10630)
at n.set (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:16:725)
at n.cancel (https://XXX/assets/YYY-707bc84342df7a5350ea91fcc2b9bf53.js:1:20788)
at o.join (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:7:6400)
at Function.u.join (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:13:12315)
at https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:9:30923
at Object.h [as flaggedInstrument] (https://XXX/assets/vendor-c3ea8aab9a11f79411cf3b32532ea544.js:12:18911)

由于所有内容都引用了/assets/vendor-*.js文件,因此很难准确地找出错误发生的位置。

Since everything refers to /assets/vendor-*.js files, it is very laborious to find out exactly where the error has occurred.

此刻,我尝试根据访问的端点和我对软件的了解来推断错误发生的位置。但是,这是非常不可靠且没有结构的,因为考虑到我的代码库的大小,错误通常非常模糊。

At the moment, I try to deduce where the error has occurred based on the endpoint accessed and my knowledge of the software. However, this is highly unreliable and unstructured, since the errors are very often highly vague, given the size of my code base.

例如,在这里,很明显调用indexOf()的对象(可能是数组)可能未定义或为null,因此,对其调用indexOf()无效,因此会出错。但是,猜猜在数百个大型源文件中有多少个数组使用indexOf();-)

For instance here, it is obvious that an object on which indexOf() is called (presumably an array) is probably undefined or null and, as such, calling indexOf() on it doesn't work, hence the error. But guess how many arrays use indexOf() in a couple of hundred large-ish source files ;-)

有没有更好,更结构化的方法可供我使用在这种情况下调试?

Is there a better, more structured approach that I can use to debug in such situations?

推荐答案

通过在Chrome调试器中将暂停异常并检查其内容,您可能能够看到库js文件发生故障的库。之后,您可以将ember-cli-build.js中的库引用从libraryx.js更改为libraryx.src.js或特定库的等效项。

You may be able to see the library js file used by putting 'pause on exceptions' in chromium debugger and checking what's the library that has the line of failure. After that, you may change the library reference in ember-cli-build.js from libraryx.js to libraryx.src.js or equivalent for the particular library.

这篇关于ember.js:如何根据资产/供应商* .js进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆