mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-15 07:57:09 +03:00
Retry for errors again
This commit is contained in:
@@ -117,8 +117,8 @@ let submissionNotice: SubmissionNotice = null;
|
|||||||
// If there is an advert playing (or about to be played), this is true
|
// If there is an advert playing (or about to be played), this is true
|
||||||
let isAdPlaying = false;
|
let isAdPlaying = false;
|
||||||
|
|
||||||
// last response status
|
|
||||||
let lastResponseStatus: number;
|
let lastResponseStatus: number;
|
||||||
|
let retryCount = 0;
|
||||||
|
|
||||||
// Contains all of the functions and variables needed by the skip notice
|
// Contains all of the functions and variables needed by the skip notice
|
||||||
const skipNoticeContentContainer: ContentContainer = () => ({
|
const skipNoticeContentContainer: ContentContainer = () => ({
|
||||||
@@ -275,6 +275,7 @@ if (!Config.configSyncListeners.includes(contentConfigUpdateListener)) {
|
|||||||
function resetValues() {
|
function resetValues() {
|
||||||
lastCheckTime = 0;
|
lastCheckTime = 0;
|
||||||
lastCheckVideoTime = -1;
|
lastCheckVideoTime = -1;
|
||||||
|
retryCount = 0;
|
||||||
|
|
||||||
//reset sponsor times
|
//reset sponsor times
|
||||||
sponsorTimes = null;
|
sponsorTimes = null;
|
||||||
@@ -851,7 +852,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
|||||||
?.map((video) => video.segments)[0];
|
?.map((video) => video.segments)[0];
|
||||||
if (!recievedSegments || !recievedSegments.length) {
|
if (!recievedSegments || !recievedSegments.length) {
|
||||||
// return if no video found
|
// return if no video found
|
||||||
retryFetch();
|
retryFetch(404);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,9 +914,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
|||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lastResponseStatus === 404) {
|
retryFetch(lastResponseStatus);
|
||||||
retryFetch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.config.isVip) {
|
if (Config.config.isVip) {
|
||||||
@@ -949,16 +948,23 @@ async function lockedCategoriesLookup(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function retryFetch(): void {
|
function retryFetch(errorCode: number): void {
|
||||||
if (!Config.config.refetchWhenNotFound) return;
|
if (!Config.config.refetchWhenNotFound) return;
|
||||||
|
|
||||||
sponsorDataFound = false;
|
sponsorDataFound = false;
|
||||||
|
|
||||||
|
if (errorCode !== 404 && retryCount > 1) {
|
||||||
|
// Too many errors (50x), give up
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
retryCount++;
|
||||||
|
|
||||||
|
const delay = errorCode === 404 ? (10000 + Math.random() * 30000) : (2000 + Math.random() * 10000);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (sponsorVideoID && sponsorTimes?.length === 0) {
|
if (sponsorVideoID && sponsorTimes?.length === 0) {
|
||||||
sponsorsLookup();
|
sponsorsLookup();
|
||||||
}
|
}
|
||||||
}, 10000 + Math.random() * 30000);
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user