@onlineapps/mq-client-core 1.0.69 → 1.0.70

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": "@onlineapps/mq-client-core",
3
- "version": "1.0.69",
3
+ "version": "1.0.70",
4
4
  "description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -419,6 +419,7 @@ class RabbitMQClient extends EventEmitter {
419
419
  * @throws {Error} If connection or channel creation fails.
420
420
  */
421
421
  async connect() {
422
+ let connectTimeoutTimer = null;
422
423
  try {
423
424
  const rawTarget = this._config.host || this._config.url;
424
425
  const heartbeat = this._config.heartbeat ?? 30;
@@ -433,9 +434,11 @@ class RabbitMQClient extends EventEmitter {
433
434
  : [{ ...rawTarget, heartbeat, clientProperties: { connection_name: connectionName } }];
434
435
 
435
436
  const connectPromise = amqp.connect(...connectArgs);
436
- let connectTimeoutTimer = null;
437
437
  const timeoutPromise = new Promise((_, reject) => {
438
438
  connectTimeoutTimer = setTimeout(() => reject(new Error('Connection timeout after 10 seconds')), 10000);
439
+ if (connectTimeoutTimer && typeof connectTimeoutTimer.unref === 'function') {
440
+ connectTimeoutTimer.unref();
441
+ }
439
442
  });
440
443
  console.log('[RabbitMQClient] Starting connection race...');
441
444
  this._connection = await Promise.race([connectPromise, timeoutPromise]);
@@ -537,6 +540,11 @@ class RabbitMQClient extends EventEmitter {
537
540
  this._connection = null;
538
541
  }
539
542
  throw err;
543
+ } finally {
544
+ if (connectTimeoutTimer) {
545
+ clearTimeout(connectTimeoutTimer);
546
+ connectTimeoutTimer = null;
547
+ }
540
548
  }
541
549
  }
542
550