elasticio-sailor-nodejs 2.7.7 → 2.7.8

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/.nsprc CHANGED
@@ -2,5 +2,13 @@
2
2
  "GHSA-f8q6-p94x-37v3": {
3
3
  "active": true,
4
4
  "notes": "braceExpand is not used in rimraf"
5
+ },
6
+ "GHSA-4hjh-wcwx-xvwj": {
7
+ "active": true,
8
+ "notes": "should be removed when maester-client is fixed: https://github.com/elasticio/maester-client/issues/47"
9
+ },
10
+ "GHSA-869p-cjfg-cm3x": {
11
+ "active": true,
12
+ "notes": "we don't use HMAC signature"
5
13
  }
6
14
  }
package/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 2.7.7 (August 5, 2025)
1
+ ## 2.7.8 (February 4, 2026)
2
+
3
+ * Ensure connection before ack/nack of the message
4
+ [#7855](https://github.com/elasticio/elasticio/issues/7855)
5
+
6
+ ## 2.7.7 (November 19, 2025)
2
7
 
3
8
  * Improve handling of cases when connection to RabbitMQ is re-established.
4
9
  [#7855](https://github.com/elasticio/elasticio/issues/7855)
package/lib/amqp.js CHANGED
@@ -336,16 +336,39 @@ class Amqp {
336
336
  return message;
337
337
  }
338
338
 
339
+ async getMessageToAck(messageId) {
340
+ let message;
341
+ let retryCount = 0;
342
+ for (let i = 0; i <= this.settings.AMQP_PUBLISH_RETRY_ATTEMPTS; i++) {
343
+ await this._ensureConsumerChannel();
344
+ message = await this.getMostRecentMessage(messageId);
345
+ if (this.consumerChannel) {
346
+ break;
347
+ }
348
+ // Make sure consumer channel is available after receiving the message
349
+ log.debug({ messageId, retryCount: retryCount++ }, 'Waiting for consumer channel to ack/nack message');
350
+ const backoffTime = this._getDelay(
351
+ this.settings.AMQP_PUBLISH_RETRY_DELAY,
352
+ this.settings.AMQP_PUBLISH_MAX_RETRY_DELAY,
353
+ retryCount
354
+ );
355
+ await this._sleep(backoffTime);
356
+ }
357
+ return message;
358
+ }
359
+
339
360
  async ack(messageId) {
340
- const message = await this.getMostRecentMessage(messageId);
361
+ const message = await this.getMessageToAck(messageId);
341
362
  log.debug(message.fields, 'Message ack');
363
+ assert(this.consumerChannel, 'Consumer channel is not available to ack message');
342
364
  this.consumerChannel.ack(message);
343
365
  messagesDB.deleteMessage(messageId);
344
366
  }
345
367
 
346
368
  async reject(messageId) {
347
- const message = await this.getMostRecentMessage(messageId);
369
+ const message = await this.getMessageToAck(messageId);
348
370
  log.debug(message.fields, 'Message reject');
371
+ assert(this.consumerChannel, 'Consumer channel is not available to reject message');
349
372
  this.consumerChannel.reject(message, false);
350
373
  messagesDB.deleteMessage(messageId);
351
374
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elasticio-sailor-nodejs",
3
3
  "description": "The official elastic.io library for bootstrapping and executing for Node.js connectors",
4
- "version": "2.7.7",
4
+ "version": "2.7.8",
5
5
  "main": "run.js",
6
6
  "scripts": {
7
7
  "audit": "better-npm-audit audit --level high --production",