Fix: add extended wait loop for Matrix User ID resolution (30s timeout)
This commit is contained in:
12
index.js
12
index.js
@@ -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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user