ember.js: how to debug based on assets/vendor-*.js

不羁岁月 提交于 2020-01-12 10:21:53

问题


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

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)

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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/45675242/ember-js-how-to-debug-based-on-assets-vendor-js

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