@motiadev/adapter-bullmq-events 0.17.6-beta.188-623819 → 0.17.7-beta.188
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ConnectionError } from "./errors.mjs";
|
|
2
1
|
import IORedis from "ioredis";
|
|
3
2
|
|
|
4
3
|
//#region src/connection-manager.ts
|
|
@@ -14,14 +13,15 @@ var ConnectionManager = class {
|
|
|
14
13
|
});
|
|
15
14
|
this.ownsConnection = true;
|
|
16
15
|
}
|
|
16
|
+
this.isClosed = false;
|
|
17
17
|
this.setupEventHandlers();
|
|
18
18
|
}
|
|
19
19
|
setupEventHandlers() {
|
|
20
20
|
this.connection.on("error", (err) => {
|
|
21
|
-
|
|
22
|
-
console.error("[BullMQ] Connection error:", error);
|
|
21
|
+
if (!this.isClosed) console.warn("[BullMQ] Connection error:", err?.message);
|
|
23
22
|
});
|
|
24
23
|
this.connection.on("close", () => {
|
|
24
|
+
this.isClosed = true;
|
|
25
25
|
console.warn("[BullMQ] Connection closed");
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.mjs","names":[],"sources":["../src/connection-manager.ts"],"sourcesContent":["import IORedis, { type Redis } from 'ioredis'\nimport
|
|
1
|
+
{"version":3,"file":"connection-manager.mjs","names":[],"sources":["../src/connection-manager.ts"],"sourcesContent":["import IORedis, { type Redis } from 'ioredis'\nimport type { BullMQConnectionConfig } from './types'\n\nexport class ConnectionManager {\n readonly connection: Redis\n readonly ownsConnection: boolean\n private isClosed: boolean\n\n constructor(config: BullMQConnectionConfig) {\n if (config instanceof IORedis) {\n this.connection = config\n this.ownsConnection = false\n } else {\n this.connection = new IORedis({\n maxRetriesPerRequest: null,\n ...config,\n })\n this.ownsConnection = true\n }\n\n this.isClosed = false\n\n this.setupEventHandlers()\n }\n\n private setupEventHandlers(): void {\n this.connection.on('error', (err: Error) => {\n if (!this.isClosed) {\n console.warn('[BullMQ] Connection error:', err?.message)\n }\n })\n\n this.connection.on('close', () => {\n this.isClosed = true\n console.warn('[BullMQ] Connection closed')\n })\n }\n\n async close(): Promise<void> {\n if (this.ownsConnection && this.connection.status !== 'end') {\n await this.connection.quit()\n }\n }\n}\n"],"mappings":";;;AAGA,IAAa,oBAAb,MAA+B;CAK7B,YAAY,QAAgC;AAC1C,MAAI,kBAAkB,SAAS;AAC7B,QAAK,aAAa;AAClB,QAAK,iBAAiB;SACjB;AACL,QAAK,aAAa,IAAI,QAAQ;IAC5B,sBAAsB;IACtB,GAAG;IACJ,CAAC;AACF,QAAK,iBAAiB;;AAGxB,OAAK,WAAW;AAEhB,OAAK,oBAAoB;;CAG3B,AAAQ,qBAA2B;AACjC,OAAK,WAAW,GAAG,UAAU,QAAe;AAC1C,OAAI,CAAC,KAAK,SACR,SAAQ,KAAK,8BAA8B,KAAK,QAAQ;IAE1D;AAEF,OAAK,WAAW,GAAG,eAAe;AAChC,QAAK,WAAW;AAChB,WAAQ,KAAK,6BAA6B;IAC1C;;CAGJ,MAAM,QAAuB;AAC3B,MAAI,KAAK,kBAAkB,KAAK,WAAW,WAAW,MACpD,OAAM,KAAK,WAAW,MAAM"}
|
package/dist/errors.mjs
CHANGED
|
@@ -19,13 +19,7 @@ var WorkerCreationError = class extends BullMQAdapterError {
|
|
|
19
19
|
this.name = "WorkerCreationError";
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
var ConnectionError = class extends BullMQAdapterError {
|
|
23
|
-
constructor(message, cause) {
|
|
24
|
-
super(`Connection error: ${message}`, cause);
|
|
25
|
-
this.name = "ConnectionError";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
22
|
|
|
29
23
|
//#endregion
|
|
30
|
-
export {
|
|
24
|
+
export { QueueCreationError, WorkerCreationError };
|
|
31
25
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":["cause?: Error"],"sources":["../src/errors.ts"],"sourcesContent":["export class BullMQAdapterError extends Error {\n constructor(\n message: string,\n public readonly cause?: Error,\n ) {\n super(message)\n this.name = 'BullMQAdapterError'\n if (cause) {\n this.stack = `${this.stack}\\nCaused by: ${cause.stack}`\n }\n }\n}\n\nexport class QueueCreationError extends BullMQAdapterError {\n constructor(queueName: string, cause?: Error) {\n super(`Failed to create queue: ${queueName}`, cause)\n this.name = 'QueueCreationError'\n }\n}\n\nexport class WorkerCreationError extends BullMQAdapterError {\n constructor(topic: string, stepName: string, cause?: Error) {\n super(`Failed to create worker for topic ${topic}, step ${stepName}`, cause)\n this.name = 'WorkerCreationError'\n }\n}\n\nexport class ConnectionError extends BullMQAdapterError {\n constructor(message: string, cause?: Error) {\n super(`Connection error: ${message}`, cause)\n this.name = 'ConnectionError'\n }\n}\n"],"mappings":";AAAA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,SACA,AAAgBA,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,MAAI,MACF,MAAK,QAAQ,GAAG,KAAK,MAAM,eAAe,MAAM;;;AAKtD,IAAa,qBAAb,cAAwC,mBAAmB;CACzD,YAAY,WAAmB,OAAe;AAC5C,QAAM,2BAA2B,aAAa,MAAM;AACpD,OAAK,OAAO;;;AAIhB,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,YAAY,OAAe,UAAkB,OAAe;AAC1D,QAAM,qCAAqC,MAAM,SAAS,YAAY,MAAM;AAC5E,OAAK,OAAO
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":["cause?: Error"],"sources":["../src/errors.ts"],"sourcesContent":["export class BullMQAdapterError extends Error {\n constructor(\n message: string,\n public readonly cause?: Error,\n ) {\n super(message)\n this.name = 'BullMQAdapterError'\n if (cause) {\n this.stack = `${this.stack}\\nCaused by: ${cause.stack}`\n }\n }\n}\n\nexport class QueueCreationError extends BullMQAdapterError {\n constructor(queueName: string, cause?: Error) {\n super(`Failed to create queue: ${queueName}`, cause)\n this.name = 'QueueCreationError'\n }\n}\n\nexport class WorkerCreationError extends BullMQAdapterError {\n constructor(topic: string, stepName: string, cause?: Error) {\n super(`Failed to create worker for topic ${topic}, step ${stepName}`, cause)\n this.name = 'WorkerCreationError'\n }\n}\n\nexport class ConnectionError extends BullMQAdapterError {\n constructor(message: string, cause?: Error) {\n super(`Connection error: ${message}`, cause)\n this.name = 'ConnectionError'\n }\n}\n"],"mappings":";AAAA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YACE,SACA,AAAgBA,OAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;AACZ,MAAI,MACF,MAAK,QAAQ,GAAG,KAAK,MAAM,eAAe,MAAM;;;AAKtD,IAAa,qBAAb,cAAwC,mBAAmB;CACzD,YAAY,WAAmB,OAAe;AAC5C,QAAM,2BAA2B,aAAa,MAAM;AACpD,OAAK,OAAO;;;AAIhB,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,YAAY,OAAe,UAAkB,OAAe;AAC1D,QAAM,qCAAqC,MAAM,SAAS,YAAY,MAAM;AAC5E,OAAK,OAAO"}
|
package/package.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.mts",
|
|
8
|
-
"version": "0.17.
|
|
8
|
+
"version": "0.17.7-beta.188",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"bullmq": "^5.63.0",
|
|
11
11
|
"ioredis": "^5.8.2",
|
|
12
12
|
"uuid": "^11.1.0",
|
|
13
|
-
"@motiadev/core": "0.17.
|
|
13
|
+
"@motiadev/core": "0.17.7-beta.188"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"rimraf": "^6.0.1",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import IORedis, { type Redis } from 'ioredis'
|
|
2
|
-
import { ConnectionError } from './errors'
|
|
3
2
|
import type { BullMQConnectionConfig } from './types'
|
|
4
3
|
|
|
5
4
|
export class ConnectionManager {
|
|
6
5
|
readonly connection: Redis
|
|
7
6
|
readonly ownsConnection: boolean
|
|
7
|
+
private isClosed: boolean
|
|
8
8
|
|
|
9
9
|
constructor(config: BullMQConnectionConfig) {
|
|
10
10
|
if (config instanceof IORedis) {
|
|
@@ -18,16 +18,20 @@ export class ConnectionManager {
|
|
|
18
18
|
this.ownsConnection = true
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
this.isClosed = false
|
|
22
|
+
|
|
21
23
|
this.setupEventHandlers()
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
private setupEventHandlers(): void {
|
|
25
27
|
this.connection.on('error', (err: Error) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
if (!this.isClosed) {
|
|
29
|
+
console.warn('[BullMQ] Connection error:', err?.message)
|
|
30
|
+
}
|
|
28
31
|
})
|
|
29
32
|
|
|
30
33
|
this.connection.on('close', () => {
|
|
34
|
+
this.isClosed = true
|
|
31
35
|
console.warn('[BullMQ] Connection closed')
|
|
32
36
|
})
|
|
33
37
|
}
|