Skip to content

Commit

Permalink
fix browser polyfill errors (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
creesch authored Aug 8, 2020
1 parent 7ece479 commit 27df3fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions extension/data/background/handlers/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ async function emptyCacheTimeout (timeoutDuration, cacheType) {
browser.tabs.sendMessage(tabs[i].id, {
action: 'tb-cache-timeout',
payload: cacheType,
}).catch(error => {
// Receiving end errors are not really relevant to us and happen a lot for iframes and such where toolbox isn't active.
if (error.message !== 'Could not establish connection. Receiving end does not exist.') {
console.warn('tb-cache-timeout: ', error.message, error);
}
});
}
}
Expand Down
7 changes: 6 additions & 1 deletion extension/data/background/handlers/globalmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ messageHandlers.set('tb-global', async (request, sender) => {
const tabs = await browser.tabs.query({});
for (let i = 0; i < tabs.length; ++i) {
if (sender.tab.id !== tabs[i].id && tabs[i].url.includes('reddit.com')) {
browser.tabs.sendMessage(tabs[i].id, message);
browser.tabs.sendMessage(tabs[i].id, message).catch(error => {
// Receiving end errors are not really relevant to us and happen a lot for iframes and such where toolbox isn't active.
if (error.message !== 'Could not establish connection. Receiving end does not exist.') {
console.warn('tb-global: ', error.message, error);
}
});
}
}

Expand Down
14 changes: 12 additions & 2 deletions extension/data/background/handlers/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ async function sendPageNotification ({title, body, url, modHash, markreadid}) {
};
const tabs = await browser.tabs.query({url: 'https://*.reddit.com/*'});
for (const tab of tabs) {
browser.tabs.sendMessage(tab.id, message);
browser.tabs.sendMessage(tab.id, message).catch(error => {
// Receiving end errors are not really relevant to us and happen a lot for iframes and such where toolbox isn't active.
if (error.message !== 'Could not establish connection. Receiving end does not exist.') {
console.warn('tb-show-page-notification: ', error.message, error);
}
});
}
return notificationID;
}
Expand Down Expand Up @@ -104,7 +109,12 @@ async function clearNotification (notificationID) {
};
const tabs = await browser.tabs.query({url: 'https://*.reddit.com/*'});
for (const tab of tabs) {
browser.tabs.sendMessage(tab.id, message);
browser.tabs.sendMessage(tab.id, message).catch(error => {
// Receiving end errors are not really relevant to us and happen a lot for iframes and such where toolbox isn't active.
if (error.message !== 'Could not establish connection. Receiving end does not exist.') {
console.warn('tb-clear-page-notification: ', error.message, error);
}
});
}
// We don't get a callback when the notifications are closed, so we just
// clean up the data here
Expand Down

0 comments on commit 27df3fd

Please sign in to comment.