mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-09-20 04:54:00 +02:00
Improve logging and fix ip fetch error breaking skip segments
This commit is contained in:
parent
e289fe9075
commit
2887a8505c
2 changed files with 14 additions and 3 deletions
|
@ -223,6 +223,8 @@ async function shouldKeepSubmission(submissions: BrandingDBSubmission[], type: B
|
||||||
return submitterIP.hashedIP === hashedIP;
|
return submitterIP.hashedIP === hashedIP;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// give up on shadow hide for now
|
// give up on shadow hide for now
|
||||||
|
Logger.error(`getBranding: Error while trying to find IP: ${e}`);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -42,7 +42,10 @@ async function prepareCategorySegments(req: Request, videoID: VideoID, service:
|
||||||
const fetchData = () => privateDB.prepare("all", 'SELECT "hashedIP" FROM "sponsorTimes" WHERE "videoID" = ? AND "timeSubmitted" = ? AND "service" = ?',
|
const fetchData = () => privateDB.prepare("all", 'SELECT "hashedIP" FROM "sponsorTimes" WHERE "videoID" = ? AND "timeSubmitted" = ? AND "service" = ?',
|
||||||
[videoID, segment.timeSubmitted, service], { useReplica: true }) as Promise<{ hashedIP: HashedIP }[]>;
|
[videoID, segment.timeSubmitted, service], { useReplica: true }) as Promise<{ hashedIP: HashedIP }[]>;
|
||||||
try {
|
try {
|
||||||
if (db.highLoad() || privateDB.highLoad()) throw new Error("High load, not handling shadowhide");
|
if (db.highLoad() || privateDB.highLoad()) {
|
||||||
|
Logger.error("High load, not handling shadowhide");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted] = promiseOrTimeout(QueryCacher.get(fetchData, shadowHiddenIPKey(videoID, segment.timeSubmitted, service)), 150);
|
cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted] = promiseOrTimeout(QueryCacher.get(fetchData, shadowHiddenIPKey(videoID, segment.timeSubmitted, service)), 150);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -51,7 +54,13 @@ async function prepareCategorySegments(req: Request, videoID: VideoID, service:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ipList = await cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted];
|
let ipList = [];
|
||||||
|
try {
|
||||||
|
ipList = await cache.shadowHiddenSegmentIPs[videoID][segment.timeSubmitted];
|
||||||
|
} catch (e) {
|
||||||
|
Logger.error(`skipSegments: Error while trying to find IP: ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ipList?.length > 0 && cache.userHashedIP === undefined) {
|
if (ipList?.length > 0 && cache.userHashedIP === undefined) {
|
||||||
cache.userHashedIP = await cache.userHashedIPPromise;
|
cache.userHashedIP = await cache.userHashedIPPromise;
|
||||||
|
@ -186,7 +195,7 @@ async function getSegmentsByHash(req: Request, hashedVideoIDPrefix: VideoIDHash,
|
||||||
|
|
||||||
return segments;
|
return segments;
|
||||||
} catch (err) /* istanbul ignore next */ {
|
} catch (err) /* istanbul ignore next */ {
|
||||||
Logger.error(err as string);
|
Logger.error(`get segments by hash error: ${err}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue