Ver Fonte

ignore error when sending "onLazyTimeout" message

Gildas há 6 anos atrás
pai
commit
6c2d6137d5
1 ficheiros alterados com 7 adições e 1 exclusões
  1. 7 1
      lib/lazy/bg/lazy-timeout.js

+ 7 - 1
lib/lazy/bg/lazy-timeout.js

@@ -29,7 +29,13 @@ singlefile.lib.lazy.bg.main = (() => {
 
 
 	browser.runtime.onMessage.addListener((message, sender) => {
 	browser.runtime.onMessage.addListener((message, sender) => {
 		if (message.method == "lazyTimeout.setTimeout") {
 		if (message.method == "lazyTimeout.setTimeout") {
-			const timeoutId = setTimeout(() => browser.tabs.sendMessage(sender.tab.id, { method: "content.onLazyTimeout", id: timeoutId }), message.delay);
+			const timeoutId = setTimeout(async () => {
+				try {
+					await browser.tabs.sendMessage(sender.tab.id, { method: "content.onLazyTimeout", id: timeoutId });
+				} catch (error) {
+					// ignored
+				}
+			}, message.delay);
 			return Promise.resolve(timeoutId);
 			return Promise.resolve(timeoutId);
 		}
 		}
 		if (message.method == "lazyTimeout.clearTimeout") {
 		if (message.method == "lazyTimeout.clearTimeout") {