Skip to content

Commit aba3738

Browse files
committed
fix: broken external messaging in chrome v145
1 parent f6f1665 commit aba3738

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/extension/background.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,21 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
5757
});
5858

5959
// external messaging API to execute actions
60-
chrome.runtime.onMessageExternal.addListener(async (message, sender, sendResponse) => {
60+
chrome.runtime.onMessageExternal.addListener((message, sender, sendResponse) => {
6161
const { action } = message;
62-
let resp = null;
63-
if (typeof externalActions[action] === 'function') {
64-
resp = await externalActions[action](message, sender);
62+
63+
if (typeof externalActions[action] !== 'function') {
64+
sendResponse(null);
65+
return false;
6566
}
66-
sendResponse(resp);
67+
68+
Promise.resolve(externalActions[action](message, sender))
69+
.then(sendResponse)
70+
.catch((e) => {
71+
sendResponse({ error: e.message });
72+
});
73+
74+
return true;
6775
});
6876

6977
// Listen for changes in display state in local storage.

0 commit comments

Comments
 (0)