hotfix(better)

This commit is contained in:
NoLogicAlan committed 2026-09-22 01:24:13 +03:00
1 parent 3ea34c7f19
commit 0f3bc0f54d
10 files changed
+156 -6

No files matched your search

+1
View File
@@ -93,6 +93,7 @@ export class FluxerListManager {
"Accept": "application/json",
"User-Agent": "RemixBot/1.0 (FluxerList Integration)",
},
signal: AbortSignal.timeout(15_000),
});
if (res.status === 401) {
+3 -1
View File
@@ -1,6 +1,7 @@
/** @module src/services/TrackOptionsManager @description Per-user track options (start/end timestamps) stored in MySQL. Provides caching, matching, and CRUD for track segments. */
import mysql from "mysql2";
import { logger } from "../core/Logger.mjs";
import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "../db/MysqlGuard.mjs";
const DEFAULT_ALIAS = "default";
const MAX_ALIAS_LEN = 32;
@@ -24,7 +25,8 @@ export class TrackOptionsManager {
/** @param {object} mysqlConfig - MySQL connection config. */
constructor(mysqlConfig) {
this.db = mysql.createPool({ connectionLimit: 10, ...mysqlConfig });
this.db = mysql.createPool({ ...MYSQL_POOL_DEFAULTS, connectionLimit: 10, ...mysqlConfig });
attachMysqlPoolGuard(this.db, "TrackOptions");
this.db.on("error", (err) => {
logger.error("[TrackOptions] MySQL pool error:", err.code ?? err.message);
});
+3
View File
@@ -14,6 +14,7 @@ import { logger } from "../../core/Logger.mjs";
import { normalizeTrackText } from "./constants.mjs";
import { applyMixins } from "../../utils/mixins.mjs";
import { parseLastFmUrl, isLastFmUrl } from "./urlUtils.mjs";
import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "../../db/MysqlGuard.mjs";
import UserStoreMixin from "./UserStoreMixin.mjs";
import ScrobblingMixin from "./ScrobblingMixin.mjs";
import TrackQueriesMixin from "./TrackQueriesMixin.mjs";
@@ -140,12 +141,14 @@ export class LastFmManager {
if (this._pool) return this._pool;
const mysql = await import("mysql2/promise");
this._pool = mysql.createPool({
...MYSQL_POOL_DEFAULTS,
host: this._mysqlConfig.host,
port: this._mysqlConfig.port ?? 3306,
user: this._mysqlConfig.user,
password: this._mysqlConfig.password,
database: this._mysqlConfig.database,
});
attachMysqlPoolGuard(this._pool, "LastFm");
await this._initTable();
return this._pool;
}
+2
View File
@@ -184,6 +184,7 @@ const UserQueriesMixin = {
const profileUrl = `https://www.last.fm/user/${encodeURIComponent(user.username)}/playlists`;
const res = await fetch(profileUrl, {
headers: { "User-Agent": "RemixBot/1.0 (Last.fm Integration)" },
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) {
@@ -250,6 +251,7 @@ const UserQueriesMixin = {
const res = await fetch(playlistUrl, {
headers: { "User-Agent": "RemixBot/1.0 (Last.fm Integration)" },
signal: AbortSignal.timeout(15_000),
});
if (!res.ok) {
+5 -1
View File
@@ -23,6 +23,9 @@ function buildSignature(params, apiSecret) {
return crypto.createHash("md5").update(str + apiSecret).digest("hex");
}
/** @private @type {number} @description AbortSignal timeout (ms) for Last.fm API calls — prevents stalled TCP connections from hanging for the OS-level timeout (~15 min). */
const LASTFM_FETCH_TIMEOUT_MS = 15_000;
/** @private Make an authenticated Last.fm API call. @async @param {object} params @param {string} apiSecret @param {boolean} [post=false] @returns {Promise<object>} @throws {Error} On HTTP or Last.fm API error. */
async function apiCall(params, apiSecret, post = false) {
const allParams = { ...params };
@@ -36,8 +39,9 @@ async function apiCall(params, apiSecret, post = false) {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(allParams).toString(),
signal: AbortSignal.timeout(LASTFM_FETCH_TIMEOUT_MS),
}
: {};
: { signal: AbortSignal.timeout(LASTFM_FETCH_TIMEOUT_MS) };
const res = await fetch(url, opts);
if (!res.ok) {