@matterbridge/thread 3.9.2-dev-20260624-3362db6 → 3.9.2-dev-20260625-1591faa
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/dist/threadsManager.js +8 -3
- package/package.json +3 -3
package/dist/threadsManager.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Worker } from 'node:worker_threads';
|
|
|
5
5
|
import { hasParameter } from '@matterbridge/utils/cli';
|
|
6
6
|
import { getErrorMessage } from '@matterbridge/utils/error';
|
|
7
7
|
import { logModuleLoaded } from '@matterbridge/utils/loader';
|
|
8
|
-
import { AnsiLogger, CYAN, db, debugStringify, MAGENTA, wr } from 'node-ansi-logger';
|
|
8
|
+
import { AnsiLogger, CYAN, db, debugStringify, ft, MAGENTA, wr } from 'node-ansi-logger';
|
|
9
9
|
import { BroadcastServer } from './broadcastServer.js';
|
|
10
10
|
logModuleLoaded('ThreadsManager');
|
|
11
11
|
export class ThreadsManager {
|
|
@@ -106,6 +106,9 @@ export class ThreadsManager {
|
|
|
106
106
|
throw new Error(`Thread ${name} is already running with thread ID ${threadInfo.worker.threadId}`);
|
|
107
107
|
}
|
|
108
108
|
const path = this.resolvePath(threadInfo.path);
|
|
109
|
+
if (!fs.existsSync(path)) {
|
|
110
|
+
throw new Error(`Thread ${name} file not found at path ${path}`);
|
|
111
|
+
}
|
|
109
112
|
this.log.debug(`Starting thread ${threadInfo.name} from path ${path} type ${threadInfo.type}...`);
|
|
110
113
|
threadInfo.lastStarted = undefined;
|
|
111
114
|
threadInfo.lastStopped = undefined;
|
|
@@ -138,13 +141,13 @@ export class ThreadsManager {
|
|
|
138
141
|
threadInfo.errorCount = (threadInfo.errorCount ?? 0) + 1;
|
|
139
142
|
this.log.error(`Thread ${threadInfo.name} encountered a message error at ${new Date().toISOString()}`);
|
|
140
143
|
});
|
|
141
|
-
worker.once('error', () => {
|
|
144
|
+
worker.once('error', (error) => {
|
|
142
145
|
threadInfo.errorCount = (threadInfo.errorCount ?? 0) + 1;
|
|
143
146
|
const stoppedAt = Date.now();
|
|
144
147
|
threadInfo.lastStopped = stoppedAt;
|
|
145
148
|
threadInfo.lastDuration = Math.max(0, stoppedAt - (threadInfo.lastStarted ?? stoppedAt));
|
|
146
149
|
threadInfo.worker = undefined;
|
|
147
|
-
this.log.error(`Thread ${threadInfo.name} encountered an error at ${new Date(threadInfo.lastStopped).toISOString()} after running for ${threadInfo.lastDuration} ms`);
|
|
150
|
+
this.log.error(`Thread ${threadInfo.name} encountered an error at ${new Date(threadInfo.lastStopped).toISOString()} after running for ${threadInfo.lastDuration} ms: ${getErrorMessage(error)}`);
|
|
148
151
|
});
|
|
149
152
|
this.log.debug(`Started thread ${threadInfo.name} from path ${path} type ${threadInfo.type} with thread id ${worker.threadId}`);
|
|
150
153
|
return threadInfo.worker;
|
|
@@ -170,11 +173,13 @@ export class ThreadsManager {
|
|
|
170
173
|
const candidates = [
|
|
171
174
|
path.join(currentModuleDirectory, fileName),
|
|
172
175
|
path.join(currentModuleDirectory, '..', 'dist', fileName),
|
|
176
|
+
path.join(currentModuleDirectory, 'workers', fileName),
|
|
173
177
|
];
|
|
174
178
|
for (const candidate of candidates) {
|
|
175
179
|
if (fs.existsSync(candidate))
|
|
176
180
|
return candidate;
|
|
177
181
|
}
|
|
182
|
+
this.log.fatal(`Could not find "${fileName}" in any of the candidate paths: ${debugStringify(candidates)}${ft}. Returning the first candidate as a best effort.`);
|
|
178
183
|
return candidates[0];
|
|
179
184
|
}
|
|
180
185
|
createESMWorker(name, relativePath, workerData, argv, env, execArgv, pipedOutput = false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/thread",
|
|
3
|
-
"version": "3.9.2-dev-
|
|
3
|
+
"version": "3.9.2-dev-20260625-1591faa",
|
|
4
4
|
"description": "Matterbridge thread library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"CHANGELOG.md"
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@matterbridge/types": "3.9.2-dev-
|
|
73
|
-
"@matterbridge/utils": "3.9.2-dev-
|
|
72
|
+
"@matterbridge/types": "3.9.2-dev-20260625-1591faa",
|
|
73
|
+
"@matterbridge/utils": "3.9.2-dev-20260625-1591faa",
|
|
74
74
|
"@zip.js/zip.js": "2.8.26",
|
|
75
75
|
"node-ansi-logger": "3.3.0"
|
|
76
76
|
}
|