提问人:rolinger 提问时间:11/3/2023 最后编辑:rolinger 更新时间:11/3/2023 访问量:28
cordova.js 在其自己的回调中抛出错误
cordova.js throwing error on its own callback
问:
这最近刚刚在我的 Cordova 应用程序中弹出:
ErrorIn = https://myapp/cordova.js
ErrorAt = 314 : 13
Message = Uncaught TypeError: Cannot read properties of undefined (reading 'message')
第 314 行(来自下面的函数)是:
cordova.fireWindowEvent('cordovacallbackerror', { message: msg, error: err });
那是它的......没有别的了。我无法追踪它或确定导致这种情况的原因。我唯一能够确定的另一件事是它碰巧的所有用户都在 Android 三星设备上。
Cordova CLI 11.1.0 科尔多瓦-安卓:11.0.0
下面是引发错误的函数:
/**
* Called by native code when returning the result from an action.
*/
callbackFromNative: function (callbackId, isSuccess, status, args, keepCallback) {
try {
var callback = cordova.callbacks[callbackId];
if (callback) {
if (isSuccess && status === cordova.callbackStatus.OK) {
callback.success && callback.success.apply(null, args);
} else if (!isSuccess) {
callback.fail && callback.fail.apply(null, args);
}
/*
else
Note, this case is intentionally not caught.
this can happen if isSuccess is true, but callbackStatus is NO_RESULT
which is used to remove a callback from the list without calling the callbacks
typically keepCallback is false in this case
*/
// Clear callback if not expecting any more results
if (!keepCallback) {
delete cordova.callbacks[callbackId];
}
}
} catch (err) {
var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
cordova.fireWindowEvent('cordovacallbackerror', { message: msg, error: err }); // ERROR HERE
throw err;
}
},
关于如何追踪这一点的任何建议?
答: 暂无答案
评论
cordova.js
314
cordova.js
// ERROR HERE
cordova.js