@imqueue/core 2.0.5 → 2.0.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/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # I Message Queue (@imqueue/core)
2
2
 
3
- [![Build Status](https://img.shields.io/github/actions/workflow/status/imqueue/core/build.yml)](https://github.com/imqueue/core)
4
- [![codebeat badge](https://codebeat.co/badges/b7685cb5-b290-47de-80e1-bde3e0582355)](https://codebeat.co/projects/github-com-imqueue-core-master)
5
- [![Coverage Status](https://coveralls.io/repos/github/imqueue/core/badge.svg?branch=master)](https://coveralls.io/github/imqueue/core?branch=master)
6
- [![Known Vulnerabilities](https://snyk.io/test/github/imqueue/core/badge.svg?targetFile=package.json)](https://snyk.io/test/github/imqueue/core?targetFile=package.json)
7
3
  [![License](https://img.shields.io/badge/license-GPL-blue.svg)](https://rawgit.com/imqueue/core/master/LICENSE)
8
4
 
9
5
  Simple JSON-based messaging queue for inter service communication
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/core",
3
- "version": "2.0.5",
3
+ "version": "2.0.8",
4
4
  "description": "Simple JSON-based messaging queue for inter service communication",
5
5
  "keywords": [
6
6
  "message-queue",
@@ -11,8 +11,9 @@
11
11
  "json-message"
12
12
  ],
13
13
  "scripts": {
14
+ "benchmark": "node benchmark -c $(( $(nproc) - 2 )) -m 100000",
14
15
  "prepare": "./node_modules/.bin/tsc",
15
- "test": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && ./node_modules/.bin/nyc report --reporter=text-lcov && npm run test-coverage",
16
+ "test": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && ./node_modules/.bin/nyc report --reporter=text-lcov",
16
17
  "test-fast": "./node_modules/.bin/tsc && ./node_modules/.bin/nyc mocha && /usr/bin/env node -e \"import('open').then(open => open.default('file://`pwd`/coverage/index.html', { wait: false }))\"",
17
18
  "test-local": "export COVERALLS_REPO_TOKEN=$IMQ_COVERALLS_TOKEN && npm test && /usr/bin/env node -e \"import('open').then(open => open.default('https://coveralls.io/github/imqueue/imq', { wait: false }))\"",
18
19
  "test-dev": "npm run test && npm run clean-js && npm run clean-typedefs && npm run clean-maps",
@@ -37,37 +38,36 @@
37
38
  "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
38
39
  "license": "GPL-3.0-only",
39
40
  "dependencies": {
40
- "ioredis": "^5.6.1"
41
+ "ioredis": "^5.7.0"
41
42
  },
42
43
  "devDependencies": {
43
- "@eslint/js": "^9.30.0",
44
+ "@eslint/js": "^9.33.0",
44
45
  "@types/chai": "^5.2.2",
45
46
  "@types/eslint__eslintrc": "^2.1.2",
46
47
  "@types/mocha": "^10.0.0",
47
48
  "@types/mock-require": "^3.0.0",
48
- "@types/node": "^24.0.8",
49
+ "@types/node": "^24.2.1",
49
50
  "@types/sinon": "^17.0.4",
50
51
  "@types/yargs": "^17.0.33",
51
- "@typescript-eslint/eslint-plugin": "^8.35.1",
52
- "@typescript-eslint/parser": "^8.35.1",
53
- "@typescript-eslint/typescript-estree": "^8.35.1",
54
- "chai": "^5.2.0",
55
- "codeclimate-test-reporter": "^0.5.1",
56
- "coveralls-next": "^4.2.1",
57
- "eslint": "^9.30.0",
58
- "eslint-plugin-jsdoc": "^51.3.1",
52
+ "@typescript-eslint/eslint-plugin": "^8.39.0",
53
+ "@typescript-eslint/parser": "^8.39.0",
54
+ "@typescript-eslint/typescript-estree": "^8.39.0",
55
+ "chai": "^5.2.1",
56
+ "coveralls-next": "^5.0.0",
57
+ "eslint": "^9.33.0",
58
+ "eslint-plugin-jsdoc": "^52.0.4",
59
59
  "mocha": "^11.7.1",
60
60
  "mocha-lcov-reporter": "^1.3.0",
61
61
  "mock-require": "^3.0.3",
62
62
  "nyc": "^17.1.0",
63
- "open": "^10.1.2",
63
+ "open": "^10.2.0",
64
64
  "reflect-metadata": "^0.2.2",
65
65
  "sinon": "^21.0.0",
66
66
  "source-map-support": "^0.5.21",
67
67
  "ts-node": "^10.9.2",
68
- "typedoc": "^0.28.7",
69
- "typescript": "^5.8.3",
70
- "yargs": "^17.7.2"
68
+ "typedoc": "^0.28.9",
69
+ "typescript": "^5.9.2",
70
+ "yargs": "^18.0.0"
71
71
  },
72
72
  "main": "index.js",
73
73
  "typescript": {
package/src/RedisQueue.js CHANGED
@@ -648,6 +648,9 @@ class RedisQueue extends events_1.EventEmitter {
648
648
  }
649
649
  const rx = new RegExp(`\\bname=${this.options.prefix}:[\\S]+?:watcher:`);
650
650
  const list = await this.writer.client('LIST');
651
+ if (!list || !list.split) {
652
+ return 0;
653
+ }
651
654
  return list.split(/\r?\n/).filter(client => rx.test(client)).length;
652
655
  }
653
656
  /**
@@ -12,7 +12,7 @@ var MessageType;
12
12
  exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = {
13
13
  broadcastPort: 63000,
14
14
  broadcastAddress: '255.255.255.255',
15
- aliveTimeoutCorrection: 1000,
15
+ aliveTimeoutCorrection: 2000,
16
16
  };
17
17
  const LOCALHOST_ADDRESSES = [
18
18
  'localhost',
@@ -111,41 +111,27 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
111
111
  timeout: parseFloat(timeout) * 1000,
112
112
  };
113
113
  }
114
- static serverAliveWait(cluster, server, aliveTimeoutCorrection, message) {
114
+ static serverAliveWait(cluster, server, aliveTimeoutCorrection = 0, message) {
115
115
  if (server.timer) {
116
116
  clearTimeout(server.timer);
117
117
  server.timer = undefined;
118
118
  }
119
- server.timestamp = Date.now();
120
- if (message) {
121
- server.timeout = message.timeout;
122
- }
123
- const correction = aliveTimeoutCorrection || 0;
124
- const timeout = (server.timeout || 0) + correction;
119
+ const timeout = ((message === null || message === void 0 ? void 0 : message.timeout) || 0) + aliveTimeoutCorrection;
125
120
  if (timeout <= 0) {
126
121
  return;
127
122
  }
128
- const timerId = setTimeout(() => {
129
- const existing = cluster.find(server, true);
130
- if (!existing || existing.timer !== timerId) {
131
- return;
132
- }
133
- const now = Date.now();
134
- if (!existing.timestamp) {
135
- clearTimeout(existing.timer);
136
- existing.timer = undefined;
137
- cluster.remove(existing);
123
+ server.timeout = timeout;
124
+ server.timestamp = Date.now();
125
+ server.timer = setTimeout(() => {
126
+ const entry = cluster.find(server, true);
127
+ if (typeof (entry === null || entry === void 0 ? void 0 : entry.timestamp) !== 'number') {
138
128
  return;
139
129
  }
140
- const delta = now - existing.timestamp;
141
- const currentTimeout = (existing.timeout || 0) + correction;
142
- if (delta >= currentTimeout) {
143
- clearTimeout(existing.timer);
144
- existing.timer = undefined;
145
- cluster.remove(existing);
130
+ const elapsed = Date.now() - entry.timestamp;
131
+ if (elapsed >= timeout) {
132
+ cluster.remove(entry);
146
133
  }
147
134
  }, timeout);
148
- server.timer = timerId;
149
135
  }
150
136
  /**
151
137
  * Destroys the UDPClusterManager by closing all opened network connections
@@ -166,7 +152,10 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
166
152
  if (typeof socket.close === 'function') {
167
153
  socket.removeAllListeners();
168
154
  socket.close(() => {
169
- socket === null || socket === void 0 ? void 0 : socket.unref();
155
+ // unref may be missing or not a function on mocked sockets
156
+ if (socket && typeof socket.unref === 'function') {
157
+ socket.unref();
158
+ }
170
159
  if (socketKey
171
160
  && UDPClusterManager.sockets[socketKey]) {
172
161
  delete UDPClusterManager.sockets[socketKey];