This commit is contained in:
NoLogicAlan committed 2026-09-24 03:02:37 +03:00
1 parent 2fbbdf0322
commit d21273b418
5 files changed
+80 -3

No files matched your search

+19 -1
View File
@@ -7,7 +7,7 @@
*/
import { logger } from "../../core/Logger.mjs";
import { apiCall, isLastFmUserNotFound, noteStaleUser } from "./constants.mjs";
import { apiCall, isLastFmFatalLinkError, isLastFmUserNotFound, noteStaleUser } from "./constants.mjs";
/**
* @type {object}
@@ -42,6 +42,12 @@ const ScrobblingMixin = {
}
return;
}
if (isLastFmFatalLinkError(err)) {
if (noteStaleUser(this, userId)) {
logger.warn(`[LastFm] Now-playing updates paused for ${userId}: ${err.message} (session revoked — attempting auto-recovery, will auto-unlink if unrecoverable)`);
}
return;
}
logger.warn(`[LastFm] updateNowPlaying failed for ${userId}: ${err.message}`);
}
},
@@ -77,6 +83,12 @@ const ScrobblingMixin = {
}
return;
}
if (isLastFmFatalLinkError(err)) {
if (noteStaleUser(this, userId)) {
logger.warn(`[LastFm] Scrobbling paused for ${userId}: ${err.message} (session revoked — attempting auto-recovery, will auto-unlink if unrecoverable)`);
}
return;
}
logger.warn(`[LastFm] Scrobble failed for ${userId}: ${err.message}`);
}
},
@@ -106,6 +118,12 @@ const ScrobblingMixin = {
}
return 0;
}
if (isLastFmFatalLinkError(e)) {
if (noteStaleUser(this, userId)) {
logger.warn(`[LastFm] Scrobble count sync skipped for ${userId}: ${e.message} (session revoked — attempting auto-recovery, will auto-unlink if unrecoverable)`);
}
return 0;
}
logger.warn("[LastFm] Error:", e?.message);
return 0;
}
+4 -1
View File
@@ -74,7 +74,10 @@ function isLastFmUserNotFound(err) {
function isLastFmFatalLinkError(err) {
if (isLastFmUserNotFound(err)) return true;
const msg = String(err?.message ?? "");
return /Last\.fm error 4:/.test(msg) || /authentication failed/i.test(msg);
return /Last\.fm error [49]:/.test(msg)
|| /authentication failed/i.test(msg)
|| /invalid session key/i.test(msg)
|| /Last\.fm HTTP 40[13]:/.test(msg);
}
/** @type {Set<string>} @description Users already warned about as stale (dedup for background flows). */