@onlineapps/mq-client-core 1.0.19 → 1.0.20

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.19",
3
+ "version": "1.0.20",
4
4
  "description": "Core MQ client library for RabbitMQ - shared by infrastructure services and connectors",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -59,7 +59,12 @@ class RabbitMQClient extends EventEmitter {
59
59
  */
60
60
  async connect() {
61
61
  try {
62
- this._connection = await amqp.connect(this._config.host);
62
+ // Add connection timeout to prevent hanging
63
+ const connectPromise = amqp.connect(this._config.host);
64
+ const timeoutPromise = new Promise((_, reject) => {
65
+ setTimeout(() => reject(new Error('Connection timeout after 10 seconds')), 10000);
66
+ });
67
+ this._connection = await Promise.race([connectPromise, timeoutPromise]);
63
68
  this._connection.on('error', (err) => this.emit('error', err));
64
69
  this._connection.on('close', () => {
65
70
  // Emit a connection close error to notify listeners