nestworker 2.1.0 → 2.1.3
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 +80 -2
- package/dist/core/worker.interfaces.d.ts +30 -15
- package/dist/core/worker.pool.d.ts +34 -5
- package/dist/core/worker.pool.js +388 -196
- package/dist/core/worker.pool.js.map +1 -1
- package/dist/core/worker.service.d.ts +2 -0
- package/dist/core/worker.service.js +71 -31
- package/dist/core/worker.service.js.map +1 -1
- package/dist/example/bench.d.ts +13 -0
- package/dist/example/bench.js +86 -0
- package/dist/example/bench.js.map +1 -0
- package/dist/example/image.service.d.ts +2 -0
- package/dist/example/image.service.js +10 -0
- package/dist/example/image.service.js.map +1 -1
- package/dist/example/main.js +1 -1
- package/dist/example/main.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/worker/worker-runtime.js +151 -73
- package/dist/worker/worker-runtime.js.map +1 -1
- package/package.json +10 -1
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
7
4
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
8
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
5
|
const worker_container_1 = require("../di/worker-container");
|
|
10
6
|
const services = node_worker_threads_1.workerData?.services ?? [];
|
|
11
7
|
const container = new worker_container_1.WorkerContainer();
|
|
@@ -14,20 +10,26 @@ const instances = new Map();
|
|
|
14
10
|
for (const svc of services) {
|
|
15
11
|
instances.set(svc.name, container.get(svc.name));
|
|
16
12
|
}
|
|
17
|
-
|
|
13
|
+
// Stash parentPort once — `parentPort` is a module getter; caching the
|
|
14
|
+
// reference avoids the getter call on every postMessage on the hot path.
|
|
15
|
+
const port = node_worker_threads_1.parentPort;
|
|
16
|
+
port.postMessage({ type: 'worker:ready' });
|
|
18
17
|
// ── Pending IPC calls ─────────────────────────────────────────────────────
|
|
19
18
|
const pendingIpc = new Map();
|
|
20
19
|
// ── Pending AbortControllers (keyed by abortSignalId) ────────────────────
|
|
21
20
|
const pendingAborts = new Map();
|
|
22
21
|
// ── Internal ALS for context propagation ─────────────────────────────────
|
|
23
|
-
// One ALS instance per context key — we use a single generic ALS that holds
|
|
24
|
-
// the full context map, then the user's ALS instances read from it via
|
|
25
|
-
// the context restoration path in WorkerService.
|
|
26
22
|
const workerAls = new node_async_hooks_1.AsyncLocalStorage();
|
|
27
|
-
|
|
23
|
+
// Cache built proxies per descriptor signature — proxy descriptors are
|
|
24
|
+
// static per service, but the previous code rebuilt them on every job and
|
|
25
|
+
// mutated the shared service instance each time. Cache by propertyKey.
|
|
26
|
+
const proxyCache = new Map();
|
|
27
|
+
const proxiesInstalled = new Set(); // `${serviceName}:${propertyKey}`
|
|
28
|
+
port.on('message', (msg) => {
|
|
28
29
|
const message = msg;
|
|
30
|
+
const t = message.type;
|
|
29
31
|
// IPC result from main thread
|
|
30
|
-
if (
|
|
32
|
+
if (t === 'ipc:result') {
|
|
31
33
|
const res = message;
|
|
32
34
|
const pending = pendingIpc.get(res.callId);
|
|
33
35
|
if (!pending)
|
|
@@ -37,104 +39,178 @@ node_worker_threads_1.parentPort?.on('message', (msg) => {
|
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
39
41
|
// Abort signal from main thread
|
|
40
|
-
if (
|
|
42
|
+
if (t === 'abort') {
|
|
41
43
|
const abort = message;
|
|
42
44
|
pendingAborts.get(abort.abortSignalId)?.abort();
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
// Batched jobs — process each. All sync-resolving results get auto-batched
|
|
48
|
+
// back into a single results envelope via the result flush microtask.
|
|
49
|
+
if (t === 'batch') {
|
|
50
|
+
const batch = message;
|
|
51
|
+
const jobs = batch.jobs;
|
|
52
|
+
for (let i = 0; i < jobs.length; i++)
|
|
53
|
+
runJob(jobs[i]);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Single job — pool sends this when only one job was dispatched in the
|
|
57
|
+
// schedule pass (no batching benefit to wrap a 1-element envelope).
|
|
58
|
+
runJob(message);
|
|
48
59
|
});
|
|
49
60
|
function buildProxy(descriptor) {
|
|
61
|
+
const cached = proxyCache.get(descriptor.propertyKey);
|
|
62
|
+
if (cached)
|
|
63
|
+
return cached;
|
|
50
64
|
const proxy = {};
|
|
65
|
+
const propertyKey = descriptor.propertyKey;
|
|
51
66
|
for (const methodName of descriptor.methodNames) {
|
|
52
67
|
proxy[methodName] = (...args) => new Promise((resolve, reject) => {
|
|
53
|
-
const callId =
|
|
68
|
+
const callId = ++__callCounter;
|
|
54
69
|
pendingIpc.set(callId, { resolve, reject });
|
|
55
70
|
const request = {
|
|
56
|
-
type: 'ipc:invoke',
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
type: 'ipc:invoke',
|
|
72
|
+
callId,
|
|
73
|
+
propertyKey,
|
|
74
|
+
methodName,
|
|
75
|
+
args,
|
|
59
76
|
};
|
|
60
77
|
try {
|
|
61
|
-
|
|
78
|
+
port.postMessage(request);
|
|
62
79
|
}
|
|
63
80
|
catch (err) {
|
|
64
81
|
pendingIpc.delete(callId);
|
|
65
|
-
reject(new Error(`IPC proxy "${
|
|
82
|
+
reject(new Error(`IPC proxy "${propertyKey}.${methodName}" could not serialise args: ` +
|
|
66
83
|
`${err.message}`));
|
|
67
84
|
}
|
|
68
85
|
});
|
|
69
86
|
}
|
|
87
|
+
proxyCache.set(descriptor.propertyKey, proxy);
|
|
70
88
|
return proxy;
|
|
71
89
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
// Counter-based call IDs — far cheaper than crypto.randomUUID() and only
|
|
91
|
+
// need to be unique within this worker process. Numeric IDs clone faster
|
|
92
|
+
// and hash cheaper than strings.
|
|
93
|
+
let __callCounter = 0;
|
|
94
|
+
// ── Outgoing result batching ─────────────────────────────────────────────
|
|
95
|
+
//
|
|
96
|
+
// We accumulate results into a single envelope per microtask tick. When a
|
|
97
|
+
// batch of jobs is dispatched at once, their resolved Promises all fire on
|
|
98
|
+
// the same microtask drain; the flush microtask is scheduled at the first
|
|
99
|
+
// postResult call and runs AFTER every queued .then, so it captures the
|
|
100
|
+
// entire batch and sends it in ONE postMessage. This collapses the per-job
|
|
101
|
+
// structuredClone fixed cost into a single per-batch one.
|
|
102
|
+
const resultBuffer = [];
|
|
103
|
+
let flushScheduled = false;
|
|
104
|
+
function scheduleFlush() {
|
|
105
|
+
if (flushScheduled)
|
|
106
|
+
return;
|
|
107
|
+
flushScheduled = true;
|
|
108
|
+
queueMicrotask(flushResults);
|
|
109
|
+
}
|
|
110
|
+
function flushResults() {
|
|
111
|
+
flushScheduled = false;
|
|
112
|
+
const n = resultBuffer.length;
|
|
113
|
+
if (n === 0)
|
|
114
|
+
return;
|
|
115
|
+
if (n === 1) {
|
|
116
|
+
const only = resultBuffer[0];
|
|
117
|
+
resultBuffer.length = 0;
|
|
118
|
+
port.postMessage(only);
|
|
76
119
|
return;
|
|
77
|
-
busy = true;
|
|
78
|
-
const job = queue.shift();
|
|
79
|
-
// Set up AbortController for this job
|
|
80
|
-
const abortController = new AbortController();
|
|
81
|
-
if (job.abortSignalId) {
|
|
82
|
-
pendingAborts.set(job.abortSignalId, abortController);
|
|
83
120
|
}
|
|
84
|
-
//
|
|
85
|
-
|
|
121
|
+
// Move out of the shared buffer before postMessage in case the clone
|
|
122
|
+
// triggers further microtasks that try to flush again.
|
|
123
|
+
const batch = { type: 'results', results: resultBuffer.slice(0, n) };
|
|
124
|
+
resultBuffer.length = 0;
|
|
125
|
+
port.postMessage(batch);
|
|
126
|
+
}
|
|
127
|
+
function postResult(res) {
|
|
128
|
+
resultBuffer.push(res);
|
|
129
|
+
scheduleFlush();
|
|
130
|
+
}
|
|
131
|
+
function runJob(job) {
|
|
132
|
+
// Inject proxy stubs the first time we see a (service, propertyKey) pair.
|
|
133
|
+
// Proxies are static per service — re-mutating per job was wasted work.
|
|
134
|
+
const proxyServices = job.proxyServices;
|
|
135
|
+
if (proxyServices && proxyServices.length > 0) {
|
|
86
136
|
const inst = instances.get(job.serviceName);
|
|
87
137
|
if (inst) {
|
|
88
|
-
for (
|
|
89
|
-
|
|
138
|
+
for (let i = 0; i < proxyServices.length; i++) {
|
|
139
|
+
const d = proxyServices[i];
|
|
140
|
+
const key = job.serviceName + ':' + d.propertyKey;
|
|
141
|
+
if (!proxiesInstalled.has(key)) {
|
|
142
|
+
inst[d.propertyKey] = buildProxy(d);
|
|
143
|
+
proxiesInstalled.add(key);
|
|
144
|
+
}
|
|
90
145
|
}
|
|
91
146
|
}
|
|
92
147
|
}
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
148
|
+
const jobId = job.jobId;
|
|
149
|
+
const inst = instances.get(job.serviceName);
|
|
150
|
+
if (!inst) {
|
|
151
|
+
postError(jobId, new Error(`Service "${job.serviceName}" is not registered`));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const fn = inst[job.methodName];
|
|
155
|
+
if (typeof fn !== 'function') {
|
|
156
|
+
postError(jobId, new Error(`Task "${job.serviceName}.${job.methodName}" is not registered`));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const abortSignalId = job.abortSignalId;
|
|
160
|
+
let abortController;
|
|
161
|
+
let args = job.args;
|
|
162
|
+
if (abortSignalId !== undefined) {
|
|
163
|
+
abortController = new AbortController();
|
|
164
|
+
pendingAborts.set(abortSignalId, abortController);
|
|
165
|
+
args = [...job.args, abortController.signal];
|
|
166
|
+
}
|
|
167
|
+
const finish = () => {
|
|
168
|
+
if (abortSignalId !== undefined)
|
|
169
|
+
pendingAborts.delete(abortSignalId);
|
|
109
170
|
};
|
|
171
|
+
const exec = () => inst[job.methodName](...args);
|
|
110
172
|
try {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
173
|
+
const alsContext = job.alsContext;
|
|
174
|
+
const result = alsContext !== undefined
|
|
175
|
+
? workerAls.run(alsContext, exec)
|
|
176
|
+
: exec();
|
|
177
|
+
// Sync fast path: avoid Promise allocation + microtask roundtrip when
|
|
178
|
+
// the task returned a plain value.
|
|
179
|
+
if (result === null ||
|
|
180
|
+
typeof result !== 'object' ||
|
|
181
|
+
typeof result.then !== 'function') {
|
|
182
|
+
finish();
|
|
183
|
+
postResult({ type: 'result', ok: true, data: result, jobId });
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
result.then((data) => {
|
|
187
|
+
finish();
|
|
188
|
+
postResult({ type: 'result', ok: true, data, jobId });
|
|
189
|
+
}, (error) => {
|
|
190
|
+
finish();
|
|
191
|
+
postError(jobId, error);
|
|
192
|
+
});
|
|
115
193
|
}
|
|
116
194
|
catch (error) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
name: e.name ?? 'Error',
|
|
120
|
-
message: e.message,
|
|
121
|
-
stack: e.stack,
|
|
122
|
-
code: e.code,
|
|
123
|
-
// Capture any extra own enumerable properties (e.g. HttpException.status)
|
|
124
|
-
extra: serializeExtraProps(e),
|
|
125
|
-
};
|
|
126
|
-
node_worker_threads_1.parentPort?.postMessage({ ok: false, error: serialized });
|
|
127
|
-
}
|
|
128
|
-
finally {
|
|
129
|
-
if (job.abortSignalId) {
|
|
130
|
-
pendingAborts.delete(job.abortSignalId);
|
|
131
|
-
}
|
|
132
|
-
busy = false;
|
|
133
|
-
runNext();
|
|
195
|
+
finish();
|
|
196
|
+
postError(jobId, error);
|
|
134
197
|
}
|
|
135
198
|
}
|
|
199
|
+
function postError(jobId, error) {
|
|
200
|
+
const e = error;
|
|
201
|
+
const serialized = {
|
|
202
|
+
name: e?.name ?? 'Error',
|
|
203
|
+
message: e?.message ?? String(error),
|
|
204
|
+
stack: e?.stack,
|
|
205
|
+
code: e?.code,
|
|
206
|
+
extra: serializeExtraProps(e),
|
|
207
|
+
};
|
|
208
|
+
postResult({ type: 'result', ok: false, error: serialized, jobId });
|
|
209
|
+
}
|
|
136
210
|
function serializeExtraProps(err) {
|
|
137
|
-
|
|
211
|
+
if (!err || typeof err !== 'object')
|
|
212
|
+
return undefined;
|
|
213
|
+
const skip = SKIP_ERR_KEYS;
|
|
138
214
|
const extra = {};
|
|
139
215
|
let hasExtra = false;
|
|
140
216
|
for (const key of Object.keys(err)) {
|
|
@@ -145,8 +221,10 @@ function serializeExtraProps(err) {
|
|
|
145
221
|
extra[key] = err[key];
|
|
146
222
|
hasExtra = true;
|
|
147
223
|
}
|
|
148
|
-
catch { /* skip non-cloneable */
|
|
224
|
+
catch { /* skip non-cloneable */
|
|
225
|
+
}
|
|
149
226
|
}
|
|
150
227
|
return hasExtra ? extra : undefined;
|
|
151
228
|
}
|
|
229
|
+
const SKIP_ERR_KEYS = new Set(['name', 'message', 'stack', 'code']);
|
|
152
230
|
//# sourceMappingURL=worker-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../../src/worker/worker-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../../src/worker/worker-runtime.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,uDAAqD;AACrD,6DAAyD;AAezD,MAAM,QAAQ,GAAwB,gCAAU,EAAE,QAAQ,IAAI,EAAE,CAAC;AACjE,MAAM,SAAS,GAAG,IAAI,kCAAe,EAAE,CAAC;AACxC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AA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E,CAAC,EAAE,IAAI;QACb,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;KAC9B,CAAC;IACF,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,mBAAmB,CAC1B,GAAoC;IAEpC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,IAAI,GAAG,aAAa,CAAC;IAC3B,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC;YACH,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,KAAK,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC,CAAC,wBAAwB;QAClC,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestworker",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Enterprise-grade worker thread module for NestJS — priority pool, auto-discovery, DI in workers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
7
15
|
"files": [
|
|
8
16
|
"dist",
|
|
9
17
|
"README.md",
|
|
@@ -13,6 +21,7 @@
|
|
|
13
21
|
"build": "tsc -p tsconfig.build.json",
|
|
14
22
|
"build:watch": "tsc -p tsconfig.build.json --watch",
|
|
15
23
|
"example": "npm run build && node dist/example/main.js",
|
|
24
|
+
"bench": "npm run build && node dist/example/bench.js",
|
|
16
25
|
"prepublishOnly": "npm run build"
|
|
17
26
|
},
|
|
18
27
|
"keywords": [
|