From 8d0a4ec2e6a76066e5ceadd0cb023f01f21b9750 Mon Sep 17 00:00:00 2001 From: Ajay Date: Wed, 23 Nov 2022 23:37:52 -0500 Subject: [PATCH] Fix race condition causing double fetch --- src/content.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index a137433d..36907ab4 100644 --- a/src/content.ts +++ b/src/content.ts @@ -154,6 +154,7 @@ let isAdPlaying = false; let lastResponseStatus: number; let retryCount = 0; +let lookupWaiting = false; // Contains all of the functions and variables needed by the skip notice const skipNoticeContentContainer: ContentContainer = () => ({ @@ -965,10 +966,15 @@ function setupCategoryPill() { } async function sponsorsLookup(keepOldSubmissions = true) { + if (lookupWaiting) return; if (!video || !isVisible(video)) refreshVideoAttachments(); //there is still no video here if (!video) { - setTimeout(() => sponsorsLookup(), 100); + lookupWaiting = true; + setTimeout(() => { + lookupWaiting = false; + sponsorsLookup() + }, 100); return; }