arisa 2.3.22 → 2.3.23
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/package.json +1 -1
- package/src/daemon/index.ts +19 -5
package/package.json
CHANGED
package/src/daemon/index.ts
CHANGED
|
@@ -262,11 +262,25 @@ void autoInstallMissingClis();
|
|
|
262
262
|
// --- Start Core process ---
|
|
263
263
|
startCore();
|
|
264
264
|
|
|
265
|
-
// --- Connect Telegram ---
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
// --- Connect Telegram (with retry for 409 conflict from stale polling sessions) ---
|
|
266
|
+
(async function connectTelegram(maxRetries = 5) {
|
|
267
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
268
|
+
try {
|
|
269
|
+
await telegram.connect();
|
|
270
|
+
return; // connected — polling continues in background
|
|
271
|
+
} catch (error) {
|
|
272
|
+
const is409 = String(error).includes("409");
|
|
273
|
+
if (is409 && attempt < maxRetries) {
|
|
274
|
+
const wait = attempt * 5;
|
|
275
|
+
log.warn(`Telegram 409 conflict (attempt ${attempt}/${maxRetries}), retrying in ${wait}s...`);
|
|
276
|
+
await new Promise((r) => setTimeout(r, wait * 1000));
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
log.error(`Telegram connection failed: ${error}`);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
})();
|
|
270
284
|
|
|
271
285
|
// --- Graceful shutdown ---
|
|
272
286
|
function shutdown() {
|