Fix: add extended wait loop for Matrix User ID resolution (30s timeout)

This commit is contained in:
unfunny
2026-09-13 15:24:56 -04:00
parent 18f36a7c5f
commit fadb6235fe

View File

@@ -49,16 +49,14 @@ function loadQuotes() {
await client.startClient(); await client.startClient();
console.log('✅ MatrixClient connected and authenticated\n'); console.log('✅ MatrixClient connected and authenticated\n');
// The M_INVALID_PARAM error often happens if we try to access properties console.log('⏳ Waiting for User Identity to resolve...');
// before the user profile is fully loaded.
// Let's wait for the user identity to be available.
let attempts = 0; let attempts = 0;
while (!client.user || !client.user.userId) { while (!client.user || !client.user.userId) {
if (attempts > 15) { if (attempts > 30) {
throw new Error('Timeout waiting for Matrix UserID resolution.'); throw new Error('Timeout waiting for Matrix User ID resolution (30s).');
} }
console.log(`⏳ Waiting for User ID (Attempt ${attempts + 1})...`); console.log(` ... Waiting for UserID (Attempt ${attempts + 1})`);
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 1000));
attempts++; attempts++;
} }