我遇到了未正确捕获 XHR 错误的问题。我正在使用 Offline.js 库进行一些检查。
库正在执行的代码是:
Offline.checks.xhr = function() {
var e, xhr;
xhr = new XMLHttpRequest;
xhr.offline = false;
xhr.open(Offline.getOption('checks.xhr.type'), Offline.getOption('checks.xhr.url'), true);
if (xhr.timeout != null) {
xhr.timeout = Offline.getOption('checks.xhr.timeout');
}
checkXHR(xhr, Offline.markUp, Offline.markDown);
try {
xhr.send();
} catch (_error) {
e = _error;
Offline.markDown();
}
return xhr;
};
我怀疑捕获并没有真正捕获所有东西。然后发生的是其他一些请求/承诺被中止。这会在我的应用程序中导致其他副作用。
有没有人有过类似的事情?这是否正确完成?