Spaces:
Sleeping
Sleeping
TheTapTap800 commited on
Commit ·
a4313e4
1
Parent(s): 8aee47f
Fix spawn timeout race with Microsoft auth flow
Browse files
server.js
CHANGED
|
@@ -113,6 +113,8 @@ function createBot(config) {
|
|
| 113 |
};
|
| 114 |
|
| 115 |
// Microsoft account authentication support
|
|
|
|
|
|
|
| 116 |
if (auth === 'microsoft') {
|
| 117 |
const authCacheDir = path.join(__dirname, '.auth-cache');
|
| 118 |
try {
|
|
@@ -122,6 +124,8 @@ function createBot(config) {
|
|
| 122 |
} catch (e) {}
|
| 123 |
botOptions.profilesFolder = authCacheDir;
|
| 124 |
botOptions.onMsaCode = (data) => {
|
|
|
|
|
|
|
| 125 |
sendLog(username, 'warn', `Microsoft-Authentifizierung erforderlich! Besuche ${data.verification_uri || 'https://microsoft.com/link'} und gib den Code ${data.user_code} ein.`);
|
| 126 |
io.emit('microsoft-device-code', {
|
| 127 |
username,
|
|
@@ -144,7 +148,7 @@ function createBot(config) {
|
|
| 144 |
bots[username].instance = bot;
|
| 145 |
|
| 146 |
// Spawn timeout: disconnect and retry if bot doesn't spawn within 60s
|
| 147 |
-
|
| 148 |
if (bots[username] && bots[username].status === 'connecting') {
|
| 149 |
sendLog(username, 'error', 'Timeout: Bot wurde nicht gespawnt (60s). Starte Wiederverbindung...');
|
| 150 |
try { bot.end(); } catch (e) {}
|
|
|
|
| 113 |
};
|
| 114 |
|
| 115 |
// Microsoft account authentication support
|
| 116 |
+
let spawnTimeout;
|
| 117 |
+
|
| 118 |
if (auth === 'microsoft') {
|
| 119 |
const authCacheDir = path.join(__dirname, '.auth-cache');
|
| 120 |
try {
|
|
|
|
| 124 |
} catch (e) {}
|
| 125 |
botOptions.profilesFolder = authCacheDir;
|
| 126 |
botOptions.onMsaCode = (data) => {
|
| 127 |
+
// Clear spawn timeout during auth – MS flow can take up to 15min
|
| 128 |
+
clearTimeout(spawnTimeout);
|
| 129 |
sendLog(username, 'warn', `Microsoft-Authentifizierung erforderlich! Besuche ${data.verification_uri || 'https://microsoft.com/link'} und gib den Code ${data.user_code} ein.`);
|
| 130 |
io.emit('microsoft-device-code', {
|
| 131 |
username,
|
|
|
|
| 148 |
bots[username].instance = bot;
|
| 149 |
|
| 150 |
// Spawn timeout: disconnect and retry if bot doesn't spawn within 60s
|
| 151 |
+
spawnTimeout = setTimeout(() => {
|
| 152 |
if (bots[username] && bots[username].status === 'connecting') {
|
| 153 |
sendLog(username, 'error', 'Timeout: Bot wurde nicht gespawnt (60s). Starte Wiederverbindung...');
|
| 154 |
try { bot.end(); } catch (e) {}
|