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 => { | ||||
|                 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) { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user