rascal 14.4.2 → 14.4.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 14.4.5
4
+
5
+ - Fixed issue where a partial password could be logged in debug - See https://github.com/guidesmiths/rascal/issues/200 - thanks @matt1097
6
+
7
+ ## 14.4.4
8
+
9
+ - Fixed issue where channels were not returned to the pool after publishing a large messag - See https://github.com/guidesmiths/rascal/issues/199
10
+
11
+ ## 14.4.3
12
+
13
+ - Bump dependencies
14
+ - superagent
15
+ - chance
16
+ - zUnit
17
+ - debug
18
+ - generic-pool
19
+ - lru-cache
20
+ - xregexp
21
+ - stashback
22
+ - chalk
23
+ - amqplib
24
+
3
25
  ## 14.4.2
4
26
 
5
27
  - Remove timeout for filling the channel pool since generic-pool already has this option.
@@ -169,6 +169,7 @@ function addListeners(channel, errorHandler, returnHandler) {
169
169
  }
170
170
 
171
171
  function removeListeners(channel, errorHandler, returnHandler) {
172
+ channel.removeAllListeners('drain');
172
173
  channel.removeListener('error', errorHandler);
173
174
  channel.removeListener('return', returnHandler);
174
175
  channel.connection.removeListener('error', errorHandler);
@@ -177,37 +178,65 @@ function removeListeners(channel, errorHandler, returnHandler) {
177
178
 
178
179
  function publishToExchange(channel, content, config, next) {
179
180
  debug('Publishing %d bytes to exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
180
- const ok = channel.publish(config.destination, config.routingKey, content, config.options);
181
- next(null, ok);
181
+
182
+ const fn = () => {
183
+ return channel.publish(config.destination, config.routingKey, content, config.options);
184
+ };
185
+
186
+ publishNoConfirm(fn, channel, next);
182
187
  }
183
188
 
184
189
  function publishToConfirmExchange(channel, content, config, next) {
185
190
  debug('Publishing %d bytes to confirm exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
186
191
 
187
- const once = _.once(next);
188
- const timeout = config.timeout ? setConfirmationTimeout(config.timeout, config.destination, once) : null;
192
+ const fn = (cb) => {
193
+ return channel.publish(config.destination, config.routingKey, content, config.options, cb);
194
+ };
189
195
 
190
- const ok = channel.publish(config.destination, config.routingKey, content, config.options, (err) => {
191
- clearTimeout(timeout);
192
- once(err, ok);
193
- });
196
+ publishAndConfirm(fn, channel, config, next);
194
197
  }
195
198
 
196
199
  function sendToQueue(channel, content, config, next) {
197
200
  debug('Publishing %d bytes to queue: %s', content.length, config.queue);
198
- const ok = channel.sendToQueue(config.destination, content, config.options);
199
- next(null, ok);
201
+
202
+ const fn = () => {
203
+ return channel.sendToQueue(config.destination, content, config.options);
204
+ };
205
+
206
+ publishNoConfirm(fn, channel, next);
200
207
  }
201
208
 
202
209
  function sendToConfirmQueue(channel, content, config, next) {
203
210
  debug('Publishing %d bytes to queue: %s', content.length, config.queue);
204
211
 
212
+ const fn = (cb) => {
213
+ return channel.sendToQueue(config.destination, content, config.options, cb);
214
+ };
215
+
216
+ publishAndConfirm(fn, channel, config, next);
217
+ }
218
+
219
+ function publishNoConfirm(fn, channel, next) {
220
+ let drained = false;
221
+ channel.once('drain', () => {
222
+ drained = true;
223
+ });
224
+
225
+ const ok = fn();
226
+ next(null, ok || drained);
227
+ }
228
+
229
+ function publishAndConfirm(fn, channel, config, next) {
205
230
  const once = _.once(next);
206
231
  const timeout = config.timeout ? setConfirmationTimeout(config.timeout, config.destination, once) : null;
232
+ let drained = false;
233
+ channel.once('drain', () => {
234
+ drained = true;
235
+ });
207
236
 
208
- const ok = channel.sendToQueue(config.destination, content, config.options, (err) => {
237
+ const ok = fn((err) => {
209
238
  clearTimeout(timeout);
210
- next(err, ok);
239
+ next(err, ok || drained);
211
240
  });
212
241
  }
213
242
 
@@ -76,7 +76,7 @@ module.exports = _.curry((rascalConfig, next) => {
76
76
  connection.pathname = connection.vhost === '/' ? '' : connection.vhost;
77
77
  connection.query = connection.options;
78
78
  connection.url = connection.url || url.format(connection);
79
- connection.loggableUrl = connection.url.replace(/:[^:]*?@/, ':***@');
79
+ connection.loggableUrl = connection.url.replace(/:[^:]*@/, ':***@');
80
80
  connection.index = getConnectionIndex(vhostConfig.connectionStrategy, connection, index);
81
81
  configureManagementConnection(vhostConfig, vhostName, connection);
82
82
  }
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "rascal",
3
- "version": "14.4.2",
3
+ "version": "14.4.5",
4
4
  "description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "async": "^3.2.3",
8
- "debug": "^4.1.1",
8
+ "debug": "^4.3.4",
9
9
  "forward-emitter": "^0.1.1",
10
- "generic-pool": "^3.7.1",
10
+ "generic-pool": "^3.8.2",
11
11
  "lodash": "^4.17.21",
12
- "lru-cache": "^6.0.0",
12
+ "lru-cache": "^7.10.1",
13
13
  "safe-json-parse": "^4.0.0",
14
- "stashback": "^1.1.2",
15
- "superagent": "^6.1.0",
14
+ "stashback": "^2.0.1",
15
+ "superagent": "^7.1.3",
16
16
  "uuid": "^8.3.2",
17
- "xregexp": "^5.0.1"
17
+ "xregexp": "^5.1.0"
18
18
  },
19
19
  "devDependencies": {
20
- "amqplib": "^0.9.0",
21
- "chalk": "^4.0.0",
22
- "chance": "^1.1.4",
20
+ "amqplib": "^0.9.1",
21
+ "chalk": "^4.1.2",
22
+ "chance": "^1.1.8",
23
23
  "eslint": "^7.32.0",
24
24
  "eslint-config-prettier": "^8.3.0",
25
25
  "eslint-plugin-prettier": "^4.0.0",
26
26
  "husky": "^6.0.0",
27
27
  "lint-staged": "^11.2.4",
28
28
  "nyc": "^15.1.0",
29
- "prettier": "2.4.1",
29
+ "prettier": "^2.4.1",
30
30
  "random-readable": "^1.0.1",
31
31
  "superagent-defaults": "^0.1.14",
32
- "zunit": "^3.0.8"
32
+ "zunit": "^3.2.1"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "amqplib": ">=0.5.5"