@minesa-org/mini-interaction 0.2.21 → 0.2.22
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.
|
@@ -1370,8 +1370,13 @@ export class MiniInteraction {
|
|
|
1370
1370
|
* Includes retry logic to handle race conditions where the ACK hasn't reached Discord yet.
|
|
1371
1371
|
*/
|
|
1372
1372
|
async sendFollowUp(token, response, messageId = "@original", retryCount = 0) {
|
|
1373
|
-
const MAX_RETRIES =
|
|
1374
|
-
const BASE_DELAY_MS =
|
|
1373
|
+
const MAX_RETRIES = 5;
|
|
1374
|
+
const BASE_DELAY_MS = 200; // Start with 200ms delay
|
|
1375
|
+
const INITIAL_DELAY_MS = 100; // Wait for ACK to propagate to Discord
|
|
1376
|
+
// On first attempt, add a small delay to allow ACK to propagate
|
|
1377
|
+
if (retryCount === 0) {
|
|
1378
|
+
await new Promise(resolve => setTimeout(resolve, INITIAL_DELAY_MS));
|
|
1379
|
+
}
|
|
1375
1380
|
const isEdit = messageId !== "";
|
|
1376
1381
|
const url = isEdit
|
|
1377
1382
|
? `${DISCORD_BASE_URL}/webhooks/${this.applicationId}/${token}/messages/${messageId}`
|
|
@@ -1401,7 +1406,7 @@ export class MiniInteraction {
|
|
|
1401
1406
|
const errorBody = await fetchResponse.text();
|
|
1402
1407
|
// Check for "Unknown Webhook" error (10015) - this means ACK hasn't reached Discord yet
|
|
1403
1408
|
if (fetchResponse.status === 404 && errorBody.includes("10015") && retryCount < MAX_RETRIES) {
|
|
1404
|
-
const delayMs = BASE_DELAY_MS * Math.pow(2, retryCount); // Exponential backoff:
|
|
1409
|
+
const delayMs = BASE_DELAY_MS * Math.pow(2, retryCount); // Exponential backoff: 200, 400, 800, 1600, 3200ms
|
|
1405
1410
|
console.warn(`[MiniInteraction] Webhook not ready yet, retrying in ${delayMs}ms (attempt ${retryCount + 1}/${MAX_RETRIES})`);
|
|
1406
1411
|
await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
1407
1412
|
return this.sendFollowUp(token, response, messageId, retryCount + 1);
|
package/package.json
CHANGED