aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/background.ts
diff options
context:
space:
mode:
authorAjay <[email protected]>2023-08-11 12:15:05 -0400
committerAjay <[email protected]>2023-08-11 12:15:05 -0400
commit93d695e6c28187afbb3f4c246e5370774ba3fe37 (patch)
tree1d908cb18ea7c8649decfcaaf619c15e6a4944f3 /src/background.ts
parent160924feee25fd2a0f4e7a5daa683c55172f48f0 (diff)
downloadSponsorBlock-93d695e6c28187afbb3f4c246e5370774ba3fe37.tar.gz
SponsorBlock-93d695e6c28187afbb3f4c246e5370774ba3fe37.zip
Fix error sending messages to closed popups
Diffstat (limited to 'src/background.ts')
-rw-r--r--src/background.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/background.ts b/src/background.ts
index 5b0bceb8..54fc24f6 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -27,7 +27,7 @@ const popupPort: Record<string, chrome.runtime.Port> = {};
const contentScriptRegistrations = {};
// Register content script if needed
-utils.wait(() => Config.config !== null).then(function() {
+utils.wait(() => Config.isReady()).then(function() {
if (Config.config.supportInvidious) utils.setupExtraSiteContentScripts();
});
@@ -75,7 +75,11 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
case "infoUpdated":
case "videoChanged":
if (sender.tab) {
- popupPort[sender.tab.id]?.postMessage(request);
+ try {
+ popupPort[sender.tab.id]?.postMessage(request);
+ } catch (e) {
+ // This can happen if the popup is closed
+ }
}
return false;
default: