runtime error do not interrupt promise chains

This commit is contained in:
2020-01-10 16:34:46 +08:00
parent c504942144
commit 0e62d914c1

View File

@ -23,10 +23,11 @@ function sendMessage(tab, req, log, cond, interval) {
}
chrome.tabs.sendMessage(tab.id, req, r => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError.message);
return;
}
// check error but do nothing.
// do not interrupt promise chains even if error, or the task always fail when:
// a tab is newly created, and the content scripts won't have time to initialize
chrome.runtime.lastError;
let flag = !cond || cond(r);
if (log) console.log(log, flag ? '(OK)' : '(failed)');
if (flag) {