From 1d5344145642bee7a7107d49606fcd39a525b5e1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 21 Apr 2025 08:13:16 -0400 Subject: [PATCH] [mv3] Simplify sendMessage onMessage() is now a listener installed synchrnously when uBOL executes, so no longer need to deal with failure to send messages. Related commit: https://github.com/gorhill/uBlock/commit/ab458b492a187bf5e702a04f6db78bbc43d5cd8d --- platform/mv3/extension/js/ext.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/platform/mv3/extension/js/ext.js b/platform/mv3/extension/js/ext.js index ee735b21b..ea1ab61ce 100644 --- a/platform/mv3/extension/js/ext.js +++ b/platform/mv3/extension/js/ext.js @@ -34,21 +34,8 @@ export const windows = browser.windows; // send a message, we try a few more times when the message fails to be sent. export function sendMessage(msg) { - return new Promise((resolve, reject) => { - let i = 5; - const send = ( ) => { - runtime.sendMessage(msg).then(response => { - resolve(response); - }).catch(reason => { - i -= 1; - if ( i <= 0 ) { - reject(reason); - } else { - setTimeout(send, 200); - } - }); - }; - send(); + return runtime.sendMessage(msg).catch(reason => { + console.log(reason); }); }