@dongdev/fca-unofficial 3.0.19 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/module/login.js +10 -0
- package/module/loginHelper.js +42 -20
- package/package.json +1 -1
- package/src/api/socket/listenMqtt.js +0 -1
package/CHANGELOG.md
CHANGED
package/module/login.js
CHANGED
|
@@ -20,6 +20,11 @@ if (!global.fca._errorHandlersInstalled) {
|
|
|
20
20
|
const errorCode = reason.code || reason.cause?.code;
|
|
21
21
|
const errorMessage = reason.message || String(reason);
|
|
22
22
|
|
|
23
|
+
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
24
|
+
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
25
|
+
return; // Silently ignore - already handled
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
// Handle fetch timeout errors gracefully
|
|
24
29
|
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
25
30
|
errorCode === "ETIMEDOUT" ||
|
|
@@ -54,6 +59,11 @@ if (!global.fca._errorHandlersInstalled) {
|
|
|
54
59
|
const errorMessage = error.message || String(error);
|
|
55
60
|
const errorCode = error.code;
|
|
56
61
|
|
|
62
|
+
// Suppress Sequelize instance errors (handled gracefully in getBackupModel)
|
|
63
|
+
if (errorMessage.includes("No Sequelize instance passed")) {
|
|
64
|
+
return; // Silently ignore - already handled
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
// Handle fetch/network errors
|
|
58
68
|
if (errorCode === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
59
69
|
errorCode === "ETIMEDOUT" ||
|
package/module/loginHelper.js
CHANGED
|
@@ -182,28 +182,45 @@ function cookieHeaderFromJar(j) {
|
|
|
182
182
|
let uniqueIndexEnsured = false;
|
|
183
183
|
|
|
184
184
|
function getBackupModel() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
185
|
+
try {
|
|
186
|
+
if (!models || !models.sequelize || !models.Sequelize) return null;
|
|
187
|
+
const sequelize = models.sequelize;
|
|
188
|
+
|
|
189
|
+
// Validate that sequelize is a proper Sequelize instance
|
|
190
|
+
if (!sequelize || typeof sequelize.define !== "function") return null;
|
|
191
|
+
|
|
192
|
+
const { DataTypes } = models.Sequelize;
|
|
193
|
+
if (sequelize.models && sequelize.models.AppStateBackup) return sequelize.models.AppStateBackup;
|
|
194
|
+
const dialect = typeof sequelize.getDialect === "function" ? sequelize.getDialect() : "sqlite";
|
|
195
|
+
const LongText = (dialect === "mysql" || dialect === "mariadb") ? DataTypes.TEXT("long") : DataTypes.TEXT;
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
const AppStateBackup = sequelize.define(
|
|
199
|
+
"AppStateBackup",
|
|
200
|
+
{
|
|
201
|
+
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
|
202
|
+
userID: { type: DataTypes.STRING, allowNull: false },
|
|
203
|
+
type: { type: DataTypes.STRING, allowNull: false },
|
|
204
|
+
data: { type: LongText }
|
|
205
|
+
},
|
|
206
|
+
{ tableName: "app_state_backups", timestamps: true, indexes: [{ unique: true, fields: ["userID", "type"] }] }
|
|
207
|
+
);
|
|
208
|
+
return AppStateBackup;
|
|
209
|
+
} catch (defineError) {
|
|
210
|
+
// If define fails, log and return null
|
|
211
|
+
logger(`Failed to define AppStateBackup model: ${defineError && defineError.message ? defineError.message : String(defineError)}`, "warn");
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
} catch (e) {
|
|
215
|
+
// Silently handle any errors in getBackupModel
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
async function ensureUniqueIndex(sequelize) {
|
|
205
|
-
if (uniqueIndexEnsured) return;
|
|
221
|
+
if (uniqueIndexEnsured || !sequelize) return;
|
|
206
222
|
try {
|
|
223
|
+
if (typeof sequelize.getQueryInterface !== "function") return;
|
|
207
224
|
await sequelize.getQueryInterface().addIndex("app_state_backups", ["userID", "type"], { unique: true, name: "app_state_user_type_unique" });
|
|
208
225
|
} catch { }
|
|
209
226
|
uniqueIndexEnsured = true;
|
|
@@ -225,6 +242,7 @@ async function backupAppStateSQL(j, userID) {
|
|
|
225
242
|
try {
|
|
226
243
|
const Model = getBackupModel();
|
|
227
244
|
if (!Model) return;
|
|
245
|
+
if (!models || !models.sequelize) return;
|
|
228
246
|
await Model.sync();
|
|
229
247
|
await ensureUniqueIndex(models.sequelize);
|
|
230
248
|
const appJson = getAppState(j);
|
|
@@ -910,8 +928,12 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
|
|
|
910
928
|
}
|
|
911
929
|
})
|
|
912
930
|
.catch(function (error) {
|
|
913
|
-
|
|
914
|
-
|
|
931
|
+
// Silently handle database errors - they're not critical for login
|
|
932
|
+
const errorMsg = error && error.message ? error.message : String(error);
|
|
933
|
+
if (!errorMsg.includes("No Sequelize instance passed")) {
|
|
934
|
+
// Only log non-Sequelize instance errors
|
|
935
|
+
logger(`Database connection failed: ${errorMsg}`, "warn");
|
|
936
|
+
}
|
|
915
937
|
});
|
|
916
938
|
logger("FCA fix/update by DongDev (Donix-VN)", "info");
|
|
917
939
|
const ctxMain = {
|
package/package.json
CHANGED