@tachybase/module-worker-thread 1.0.6 → 1.0.18
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/externalVersion.js +8 -8
- package/dist/server/workerManager.js +19 -1
- package/package.json +10 -10
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.0.
|
|
4
|
-
"@tachybase/schema": "1.0.
|
|
3
|
+
"@tachybase/client": "1.0.18",
|
|
4
|
+
"@tachybase/schema": "1.0.18",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/server": "1.0.
|
|
7
|
-
"@tachybase/logger": "1.0.
|
|
8
|
-
"@tachybase/module-collection": "1.0.
|
|
9
|
-
"@tachybase/module-user": "1.0.
|
|
10
|
-
"@tachybase/utils": "1.0.
|
|
11
|
-
"@tachybase/actions": "1.0.
|
|
6
|
+
"@tachybase/server": "1.0.18",
|
|
7
|
+
"@tachybase/logger": "1.0.18",
|
|
8
|
+
"@tachybase/module-collection": "1.0.18",
|
|
9
|
+
"@tachybase/module-user": "1.0.18",
|
|
10
|
+
"@tachybase/utils": "1.0.18",
|
|
11
|
+
"@tachybase/actions": "1.0.18"
|
|
12
12
|
};
|
|
@@ -93,12 +93,20 @@ const _WorkerManager = class _WorkerManager {
|
|
|
93
93
|
await Promise.all(Array.from({ length: this.workerNum }).map(() => this.addWorker()));
|
|
94
94
|
}
|
|
95
95
|
async addWorker() {
|
|
96
|
+
const maxMemory = process.env.WORKER_MAX_MEMORY || 4096;
|
|
97
|
+
const maxOldSpaceSize = `--max-old-space-size=${maxMemory}`;
|
|
96
98
|
let worker;
|
|
97
99
|
if (this.isProd) {
|
|
98
100
|
worker = new import_worker_threads.Worker(import_path.default.resolve(__dirname, `${import_constants.WORKER_FILE}.js`), {
|
|
99
101
|
workerData: {
|
|
100
102
|
appName: this.app.name,
|
|
101
103
|
databaseOptions: this.databaseOptions
|
|
104
|
+
},
|
|
105
|
+
env: {
|
|
106
|
+
...process.env,
|
|
107
|
+
...{
|
|
108
|
+
NODE_OPTIONS: maxOldSpaceSize
|
|
109
|
+
}
|
|
102
110
|
}
|
|
103
111
|
});
|
|
104
112
|
} else {
|
|
@@ -107,6 +115,12 @@ const _WorkerManager = class _WorkerManager {
|
|
|
107
115
|
scriptPath: import_path.default.resolve(__dirname, `${import_constants.WORKER_FILE}.ts`),
|
|
108
116
|
appName: this.app.name,
|
|
109
117
|
databaseOptions: this.databaseOptions
|
|
118
|
+
},
|
|
119
|
+
env: {
|
|
120
|
+
...process.env,
|
|
121
|
+
...{
|
|
122
|
+
NODE_OPTIONS: maxOldSpaceSize
|
|
123
|
+
}
|
|
110
124
|
}
|
|
111
125
|
});
|
|
112
126
|
}
|
|
@@ -323,7 +337,11 @@ const _WorkerManager = class _WorkerManager {
|
|
|
323
337
|
worker.off("message", handleMessage);
|
|
324
338
|
worker.off("error", handleError);
|
|
325
339
|
worker.off("exit", handleExit);
|
|
326
|
-
|
|
340
|
+
if (message.error) {
|
|
341
|
+
this.handleWorkerCompletion(worker, reqId, resolve, void 0, reject, message.error);
|
|
342
|
+
} else {
|
|
343
|
+
this.handleWorkerCompletion(worker, reqId, resolve, message.result);
|
|
344
|
+
}
|
|
327
345
|
}
|
|
328
346
|
};
|
|
329
347
|
handleError = (error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-worker-thread",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Worker thread for executing time-consuming tasks",
|
|
5
5
|
"main": "dist/server/index.js",
|
|
6
6
|
"dependencies": {},
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"tsx": "^4.19.2"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@tachybase/actions": "1.0.
|
|
13
|
-
"@tachybase/
|
|
14
|
-
"@tachybase/
|
|
15
|
-
"@tachybase/module-collection": "1.0.
|
|
16
|
-
"@tachybase/
|
|
17
|
-
"@tachybase/
|
|
18
|
-
"@tachybase/
|
|
19
|
-
"@tachybase/
|
|
20
|
-
"@tachybase/
|
|
12
|
+
"@tachybase/actions": "1.0.18",
|
|
13
|
+
"@tachybase/client": "1.0.18",
|
|
14
|
+
"@tachybase/logger": "1.0.18",
|
|
15
|
+
"@tachybase/module-collection": "1.0.18",
|
|
16
|
+
"@tachybase/module-user": "1.0.18",
|
|
17
|
+
"@tachybase/schema": "1.0.18",
|
|
18
|
+
"@tachybase/server": "1.0.18",
|
|
19
|
+
"@tachybase/test": "1.0.18",
|
|
20
|
+
"@tachybase/utils": "1.0.18"
|
|
21
21
|
},
|
|
22
22
|
"description.zh-CN": "工作线程,用于执行耗时任务",
|
|
23
23
|
"displayName.zh-CN": "工作线程",
|