gpt4 book ai didi

ErrorHandler error.stack 中的 Angular 2+ 路径

转载 作者:太空狗 更新时间:2023-10-29 17:59:05 24 4
gpt4 key购买 nike

我正在尝试使用 stacktrace.js 报告错误,但堆栈跟踪中的路径引用了“ng:///FormModule/MyComponent.ngfactory.js

    TypeError: Cannot read property 'push' of undefined
at Object.eval [as handleEvent] (ng:///FormModule/MyComponent.ngfactory.js:668:41)
at handleEvent (http://localhost/dist/form/angular-vendor.bundle.js:12204:138)
at callWithDebugContext (http://localhost/dist/form/angular-vendor.bundle.js:13665:42)
at Object.debugHandleEvent [as handleEvent] (http://localhost/dist/form/angular-vendor.bundle.js:13253:12)
at dispatchEvent (http://localhost/dist/form/angular-vendor.bundle.js:8808:21)
at http://localhost/dist/form/angular-vendor.bundle.js:9419:20
at HTMLAnchorElement.<anonymous> (http://localhost/dist/form/angular-vendor.bundle.js:29309:53)
at ZoneDelegate.invokeTask (http://localhost/dist/form/polyfills.bundle.js:7779:31)
at Object.onInvokeTask (http://localhost/dist/form/angular-vendor.bundle.js:4090:33)
at ZoneDelegate.invokeTask (http://localhost/dist/form/polyfills.bundle.js:7778:36)
at Zone.runTask (http://localhost/dist/form/polyfills.bundle.js:7546:47)
at HTMLAnchorElement.ZoneTask.invoke (http://localhost/dist/form/polyfills.bundle.js:7841:38)

Stacktrace.js 无法定位 bundle 文件及其对应的 source map,因为无法加载该路径

XMLHttpRequest cannot load ng:///FormModule/MyComponent.ngfactory.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

有人在使用 WebPack、Stacktrace.js 并让源映射正常工作吗,或者有人知道如何解决这个问题吗?

最佳答案

通过将 {offline: true} 作为 StackTrace.fromError 方法的第二个参数传递,修复了 Angular 6 项目中的类似问题,如下所示:

StackTrace.fromError(error, {offline: true}).then(...

按照建议here .

关于ErrorHandler error.stack 中的 Angular 2+ 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45022952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com