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