@bkmj/node-red-contrib-odbcmj 2.6.0 → 2.6.1
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.
- package/odbc.js +19 -4
- package/package.json +1 -1
package/odbc.js
CHANGED
|
@@ -399,6 +399,11 @@ module.exports = function (RED) {
|
|
|
399
399
|
// LOGIQUE PRINCIPALE (SAFE PATTERN & NON-BLOCKING UI)
|
|
400
400
|
// =====================================================================
|
|
401
401
|
this.on("input", async (msg, send, done) => {
|
|
402
|
+
// Initialisation du compteur de retry sur le message s'il n'existe pas
|
|
403
|
+
if (!msg.hasOwnProperty('_odbc_retry_attempt')) {
|
|
404
|
+
msg._odbc_retry_attempt = 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
402
407
|
// Nettoyage état précédent
|
|
403
408
|
if (this.retryTimer) { clearTimeout(this.retryTimer); this.retryTimer = null; }
|
|
404
409
|
this.isAwaitingRetry = false;
|
|
@@ -469,7 +474,9 @@ module.exports = function (RED) {
|
|
|
469
474
|
this.poolNode.resetPool();
|
|
470
475
|
}
|
|
471
476
|
|
|
472
|
-
|
|
477
|
+
// Succès : On peut retirer le compteur de l'objet msg (optionnel) ou le laisser
|
|
478
|
+
delete msg._odbc_retry_attempt;
|
|
479
|
+
done();
|
|
473
480
|
|
|
474
481
|
} catch (err) {
|
|
475
482
|
errorOccurred = err;
|
|
@@ -479,7 +486,11 @@ module.exports = function (RED) {
|
|
|
479
486
|
|| (err.odbcErrors && err.odbcErrors.length > 0)
|
|
480
487
|
);
|
|
481
488
|
|
|
482
|
-
|
|
489
|
+
// CORRECTION BUG BOUCLE INFINIE :
|
|
490
|
+
// On planifie un retry SEULEMENT si :
|
|
491
|
+
// 1. C'est une erreur de connexion OU l'option retryFresh est active
|
|
492
|
+
// 2. ET on n'a pas encore fait de retry pour ce message (compteur < 1)
|
|
493
|
+
if ((isConnectionError || this.poolNode.config.retryFreshConnection) && msg._odbc_retry_attempt < 1) {
|
|
483
494
|
shouldScheduleRetry = true;
|
|
484
495
|
}
|
|
485
496
|
} finally {
|
|
@@ -502,13 +513,17 @@ module.exports = function (RED) {
|
|
|
502
513
|
const retryDelay = parseInt(this.poolNode.config.retryDelay, 10);
|
|
503
514
|
|
|
504
515
|
if (shouldScheduleRetry && retryDelay > 0) {
|
|
505
|
-
this.warn(`Query failed (${errorOccurred.message}). Retrying in ${retryDelay}s...`);
|
|
516
|
+
this.warn(`Query failed (${errorOccurred.message}). Retrying once in ${retryDelay}s...`);
|
|
506
517
|
this.status({ fill: "red", shape: "ring", text: `Retry in ${retryDelay}s` });
|
|
507
518
|
|
|
508
519
|
this.isAwaitingRetry = true;
|
|
509
520
|
this.retryTimer = setTimeout(() => {
|
|
510
521
|
this.isAwaitingRetry = false;
|
|
511
|
-
|
|
522
|
+
|
|
523
|
+
// Incrémenter le compteur de tentatives AVANT de réémettre
|
|
524
|
+
msg._odbc_retry_attempt++;
|
|
525
|
+
|
|
526
|
+
this.log(`Retry timer expired. Re-processing message (Attempt ${msg._odbc_retry_attempt + 1}).`);
|
|
512
527
|
this.emit("input", msg, send, done);
|
|
513
528
|
}, retryDelay * 1000);
|
|
514
529
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bkmj/node-red-contrib-odbcmj",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A powerful Node-RED node to connect to any ODBC data source, with connection pooling, advanced retry logic, and result streaming.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|