@crowdin/app-project-module 0.95.0 → 0.95.2
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.
|
@@ -472,6 +472,20 @@ function consumer({ channel, config, integration, }) {
|
|
|
472
472
|
});
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
|
+
function isRetryableError(error) {
|
|
476
|
+
var _a;
|
|
477
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) {
|
|
478
|
+
const status = error.response.status;
|
|
479
|
+
if (status >= 500) {
|
|
480
|
+
return true;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
// Network errors, timeouts, and other non-HTTP errors are retryable
|
|
484
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNRESET' || (error === null || error === void 0 ? void 0 : error.code) === 'ETIMEDOUT' || (error === null || error === void 0 ? void 0 : error.code) === 'ENOTFOUND') {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
475
489
|
function processMessages({ channel, messagesToAck, webhooksData, webhooksInfo, }) {
|
|
476
490
|
return __awaiter(this, void 0, void 0, function* () {
|
|
477
491
|
try {
|
|
@@ -504,14 +518,21 @@ function processMessages({ channel, messagesToAck, webhooksData, webhooksInfo, }
|
|
|
504
518
|
}
|
|
505
519
|
}
|
|
506
520
|
catch (e) {
|
|
507
|
-
(0, logger_1.
|
|
508
|
-
// On critical error, nack all messages to requeue them
|
|
521
|
+
(0, logger_1.log)(`Error in processMessages: ${e}`);
|
|
509
522
|
for (const msg of messagesToAck) {
|
|
510
523
|
try {
|
|
511
|
-
|
|
524
|
+
if (isRetryableError(e)) {
|
|
525
|
+
// For retryable errors (5xx, network issues), requeue the message
|
|
526
|
+
channel.nack(msg, false, true);
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
// For non-retryable errors (4xx client errors), acknowledge to remove from queue
|
|
530
|
+
(0, logger_1.log)(`Non-retryable error encountered, discarding message: ${e}`);
|
|
531
|
+
channel.ack(msg);
|
|
532
|
+
}
|
|
512
533
|
}
|
|
513
|
-
catch (
|
|
514
|
-
(0, logger_1.logError)(`Error
|
|
534
|
+
catch (handleError) {
|
|
535
|
+
(0, logger_1.logError)(`Error handling message acknowledgment: ${handleError}`);
|
|
515
536
|
}
|
|
516
537
|
}
|
|
517
538
|
}
|