From 324d3800de9fde6b3383efb71be8fa74851805d6 Mon Sep 17 00:00:00 2001 From: Shiba <44804845+DeepDoge@users.noreply.github.com> Date: Mon, 24 Jan 2022 08:34:41 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=B1=20On=20error=20background=20return?= =?UTF-8?q?s=20undefined=20but=20it=20should=20throw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/background.ts | 2 +- src/scripts/ytContent.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripts/background.ts b/src/scripts/background.ts index 5e5abf4..ffe4467 100644 --- a/src/scripts/background.ts +++ b/src/scripts/background.ts @@ -17,7 +17,7 @@ async function lbryPathnameFromVideoId(videoId: string): Promise } chrome.runtime.onMessage.addListener(({ videoId }: { videoId: string }, sender, sendResponse) => { - lbryPathnameFromVideoId(videoId).then((lbryPathname) => sendResponse(lbryPathname)) + lbryPathnameFromVideoId(videoId).then((lbryPathname) => sendResponse(lbryPathname)).catch((err) => sendResponse(err)) return true }) diff --git a/src/scripts/ytContent.tsx b/src/scripts/ytContent.tsx index d267eb8..1373cfd 100644 --- a/src/scripts/ytContent.tsx +++ b/src/scripts/ytContent.tsx @@ -100,7 +100,9 @@ async function findVideoElement() { // We should get this from background, so the caching works and we don't get errors in the future if yt decides to impliment CORS async function requestLbryPathname(videoId: string) { - return await new Promise((resolve) => chrome.runtime.sendMessage({ videoId }, resolve)) + const response = await new Promise((resolve) => chrome.runtime.sendMessage({ videoId }, resolve)) + if (response instanceof Error) throw response + return response } // Start