From 4c417b10fed560c39c925dffb217b91f898a2f0f Mon Sep 17 00:00:00 2001 From: Ajay Date: Mon, 23 Sep 2024 04:05:20 -0400 Subject: [PATCH] Make sure old segment fetch request doesn't get used May fix #2101 See https://github.com/ajayyy/SponsorBlock/commit/dbf80b492902ecc55fc5b207ae5aa600be4a3bd0#r147058589 --- src/content.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/content.ts b/src/content.ts index a30bf3a5..c02db6c6 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1133,7 +1133,7 @@ function setupCategoryPill() { } async function sponsorsLookup(keepOldSubmissions = true, ignoreCache = false) { - const videoID = getVideoID() + const videoID = getVideoID(); if (!videoID) { console.error("[SponsorBlock] Attempted to fetch segments with a null/undefined videoID."); return; @@ -1141,6 +1141,9 @@ async function sponsorsLookup(keepOldSubmissions = true, ignoreCache = false) { const segmentData = await getSegmentsForVideo(videoID, ignoreCache); + // Make sure an old pending request doesn't get used. + if (videoID !== getVideoID()) return; + // store last response status lastResponseStatus = segmentData.status; if (segmentData.status === 200) {