@azteam/rabbitmq-async 1.0.139 → 1.0.141

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/rabbitmq-async",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "engines": {
@@ -17,6 +17,8 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "@azteam/util": "1.0.13",
20
- "amqplib": "0.8.0"
20
+ "amqplib": "0.8.0",
21
+ "fs-extra": "10.1.0",
22
+ "lodash": "4.17.21"
21
23
  }
22
24
  }
@@ -1,5 +1,6 @@
1
1
  import amqp from 'amqplib';
2
2
  import {timeout} from '@azteam/util';
3
+ import _ from 'lodash';
3
4
 
4
5
  class RabbitMQAsync {
5
6
  constructor(config) {
@@ -162,13 +163,19 @@ class RabbitMQAsync {
162
163
  await cb(data);
163
164
  await channel.ack(msg);
164
165
  } catch (err) {
165
- if (callbackError) {
166
- callbackError(prefixQueueName, err);
167
- }
168
- if (data.noRetry) {
169
- await channel.ack(msg);
166
+ const errString = err.toString();
167
+
168
+ if (_.some(['IllegalOperationError: Channel closed'], (el) => _.includes(errString, el))) {
169
+ reject(new Error(errString));
170
170
  } else {
171
- await channel.nack(msg);
171
+ if (callbackError) {
172
+ callbackError(prefixQueueName, err);
173
+ }
174
+ if (data.noRetry) {
175
+ await channel.ack(msg);
176
+ } else {
177
+ await channel.nack(msg);
178
+ }
172
179
  }
173
180
  }
174
181
  }