nestworker 2.1.1 → 2.1.4
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 +33 -0
- package/dist/core/worker.interfaces.d.ts +30 -15
- package/dist/core/worker.pool.d.ts +46 -5
- package/dist/core/worker.pool.js +410 -199
- package/dist/core/worker.pool.js.map +1 -1
- package/dist/core/worker.service.js +28 -15
- package/dist/core/worker.service.js.map +1 -1
- package/dist/di/worker-container.js +26 -1
- package/dist/di/worker-container.js.map +1 -1
- package/dist/example/bench.js +9 -8
- package/dist/example/bench.js.map +1 -1
- 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 +2 -2
- package/dist/example/main.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/worker/worker-runtime.js +196 -84
- package/dist/worker/worker-runtime.js.map +1 -1
- package/package.json +9 -1
|
@@ -5,25 +5,49 @@ const node_async_hooks_1 = require("node:async_hooks");
|
|
|
5
5
|
const worker_container_1 = require("../di/worker-container");
|
|
6
6
|
const services = node_worker_threads_1.workerData?.services ?? [];
|
|
7
7
|
const container = new worker_container_1.WorkerContainer();
|
|
8
|
-
container.load(services);
|
|
9
8
|
const instances = new Map();
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// Index services by name so we can lazily reconstruct each one the first
|
|
10
|
+
// time a job for it arrives. Loading ALL services synchronously before
|
|
11
|
+
// sending `worker:ready` delays the pool from dispatching ANY work to this
|
|
12
|
+
// worker — which is catastrophic for cold-burst throughput when many
|
|
13
|
+
// workers spawn together. Lazy loading lets the pool start dispatching
|
|
14
|
+
// immediately; each service pays its `vm.runInContext` cost on its first
|
|
15
|
+
// invocation and is cached for every subsequent call.
|
|
16
|
+
const servicesByName = new Map();
|
|
17
|
+
for (const svc of services)
|
|
18
|
+
servicesByName.set(svc.name, svc);
|
|
19
|
+
function getInstance(name) {
|
|
20
|
+
let inst = instances.get(name);
|
|
21
|
+
if (inst !== undefined)
|
|
22
|
+
return inst;
|
|
23
|
+
const svc = servicesByName.get(name);
|
|
24
|
+
if (svc === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
container.load([svc]);
|
|
27
|
+
inst = container.get(svc.name);
|
|
28
|
+
instances.set(svc.name, inst);
|
|
29
|
+
return inst;
|
|
12
30
|
}
|
|
13
|
-
|
|
31
|
+
// Stash parentPort once — `parentPort` is a module getter; caching the
|
|
32
|
+
// reference avoids the getter call on every postMessage on the hot path.
|
|
33
|
+
const port = node_worker_threads_1.parentPort;
|
|
34
|
+
port.postMessage({ type: 'worker:ready' });
|
|
14
35
|
// ── Pending IPC calls ─────────────────────────────────────────────────────
|
|
15
36
|
const pendingIpc = new Map();
|
|
16
37
|
// ── Pending AbortControllers (keyed by abortSignalId) ────────────────────
|
|
17
38
|
const pendingAborts = new Map();
|
|
18
39
|
// ── Internal ALS for context propagation ─────────────────────────────────
|
|
19
|
-
// One ALS instance per context key — we use a single generic ALS that holds
|
|
20
|
-
// the full context map, then the user's ALS instances read from it via
|
|
21
|
-
// the context restoration path in WorkerService.
|
|
22
40
|
const workerAls = new node_async_hooks_1.AsyncLocalStorage();
|
|
23
|
-
|
|
41
|
+
// Cache built proxies per descriptor signature — proxy descriptors are
|
|
42
|
+
// static per service, but the previous code rebuilt them on every job and
|
|
43
|
+
// mutated the shared service instance each time. Cache by propertyKey.
|
|
44
|
+
const proxyCache = new Map();
|
|
45
|
+
const proxiesInstalled = new Set(); // `${serviceName}:${propertyKey}`
|
|
46
|
+
port.on('message', (msg) => {
|
|
24
47
|
const message = msg;
|
|
48
|
+
const t = message.type;
|
|
25
49
|
// IPC result from main thread
|
|
26
|
-
if (
|
|
50
|
+
if (t === 'ipc:result') {
|
|
27
51
|
const res = message;
|
|
28
52
|
const pending = pendingIpc.get(res.callId);
|
|
29
53
|
if (!pending)
|
|
@@ -33,29 +57,54 @@ node_worker_threads_1.parentPort?.on('message', (msg) => {
|
|
|
33
57
|
return;
|
|
34
58
|
}
|
|
35
59
|
// Abort signal from main thread
|
|
36
|
-
if (
|
|
60
|
+
if (t === 'abort') {
|
|
37
61
|
const abort = message;
|
|
38
62
|
pendingAborts.get(abort.abortSignalId)?.abort();
|
|
39
63
|
return;
|
|
40
64
|
}
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
65
|
+
// Batched jobs — process each. All sync-resolving results get auto-batched
|
|
66
|
+
// back into a single results envelope via the result flush microtask.
|
|
67
|
+
if (t === 'batch') {
|
|
68
|
+
const batch = message;
|
|
69
|
+
const jobs = batch.jobs;
|
|
70
|
+
forceBuffer = true;
|
|
71
|
+
try {
|
|
72
|
+
for (let i = 0; i < jobs.length; i++)
|
|
73
|
+
runJob(jobs[i]);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
forceBuffer = false;
|
|
77
|
+
}
|
|
78
|
+
// Flush any sync results we accumulated during the loop as one envelope.
|
|
79
|
+
if (resultBuffer.length > 0) {
|
|
80
|
+
flushScheduled = true; // suppress the queued microtask flush
|
|
81
|
+
flushResults();
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Single job — pool sends this when only one job was dispatched in the
|
|
86
|
+
// schedule pass (no batching benefit to wrap a 1-element envelope).
|
|
87
|
+
runJob(message);
|
|
44
88
|
});
|
|
45
89
|
function buildProxy(descriptor) {
|
|
90
|
+
const cached = proxyCache.get(descriptor.propertyKey);
|
|
91
|
+
if (cached)
|
|
92
|
+
return cached;
|
|
46
93
|
const proxy = {};
|
|
47
94
|
const propertyKey = descriptor.propertyKey;
|
|
48
95
|
for (const methodName of descriptor.methodNames) {
|
|
49
96
|
proxy[methodName] = (...args) => new Promise((resolve, reject) => {
|
|
50
|
-
const callId =
|
|
97
|
+
const callId = ++__callCounter;
|
|
51
98
|
pendingIpc.set(callId, { resolve, reject });
|
|
52
99
|
const request = {
|
|
53
|
-
type: 'ipc:invoke',
|
|
100
|
+
type: 'ipc:invoke',
|
|
101
|
+
callId,
|
|
54
102
|
propertyKey,
|
|
55
|
-
methodName,
|
|
103
|
+
methodName,
|
|
104
|
+
args,
|
|
56
105
|
};
|
|
57
106
|
try {
|
|
58
|
-
|
|
107
|
+
port.postMessage(request);
|
|
59
108
|
}
|
|
60
109
|
catch (err) {
|
|
61
110
|
pendingIpc.delete(callId);
|
|
@@ -64,89 +113,151 @@ function buildProxy(descriptor) {
|
|
|
64
113
|
}
|
|
65
114
|
});
|
|
66
115
|
}
|
|
116
|
+
proxyCache.set(descriptor.propertyKey, proxy);
|
|
67
117
|
return proxy;
|
|
68
118
|
}
|
|
69
119
|
// Counter-based call IDs — far cheaper than crypto.randomUUID() and only
|
|
70
|
-
// need to be unique within this worker process.
|
|
120
|
+
// need to be unique within this worker process. Numeric IDs clone faster
|
|
121
|
+
// and hash cheaper than strings.
|
|
71
122
|
let __callCounter = 0;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
123
|
+
// ── Outgoing result batching ─────────────────────────────────────────────
|
|
124
|
+
//
|
|
125
|
+
// We accumulate results into a single envelope per microtask tick. When a
|
|
126
|
+
// batch of jobs is dispatched at once, their resolved Promises all fire on
|
|
127
|
+
// the same microtask drain; the flush microtask is scheduled at the first
|
|
128
|
+
// postResult call and runs AFTER every queued .then, so it captures the
|
|
129
|
+
// entire batch and sends it in ONE postMessage. This collapses the per-job
|
|
130
|
+
// structuredClone fixed cost into a single per-batch one.
|
|
131
|
+
const resultBuffer = [];
|
|
132
|
+
let flushScheduled = false;
|
|
133
|
+
// When true, postResult always buffers (we're inside a batch loop and want
|
|
134
|
+
// every sync-resolved result of that batch to coalesce into one postMessage).
|
|
135
|
+
// When false (the steady-state concurrency=1 round-trip path), the FIRST
|
|
136
|
+
// result of the tick is posted immediately and only subsequent ones buffer.
|
|
137
|
+
let forceBuffer = false;
|
|
138
|
+
function scheduleFlush() {
|
|
139
|
+
if (flushScheduled)
|
|
140
|
+
return;
|
|
141
|
+
flushScheduled = true;
|
|
142
|
+
queueMicrotask(flushResults);
|
|
143
|
+
}
|
|
144
|
+
function flushResults() {
|
|
145
|
+
flushScheduled = false;
|
|
146
|
+
const n = resultBuffer.length;
|
|
147
|
+
if (n === 0)
|
|
148
|
+
return;
|
|
149
|
+
if (n === 1) {
|
|
150
|
+
const only = resultBuffer[0];
|
|
151
|
+
resultBuffer.length = 0;
|
|
152
|
+
port.postMessage(only);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Move out of the shared buffer before postMessage in case the clone
|
|
156
|
+
// triggers further microtasks that try to flush again.
|
|
157
|
+
const batch = { type: 'results', results: resultBuffer.slice(0, n) };
|
|
158
|
+
resultBuffer.length = 0;
|
|
159
|
+
port.postMessage(batch);
|
|
160
|
+
}
|
|
161
|
+
function postResult(res) {
|
|
162
|
+
// Fast path: outside any batch loop, no flush pending, buffer empty.
|
|
163
|
+
// This is the steady-state case for single-job dispatches (concurrency=1):
|
|
164
|
+
// sending immediately removes a full microtask hop from the round-trip.
|
|
165
|
+
// Any later results arriving in the SAME tick will queue and flush as
|
|
166
|
+
// a batch as usual.
|
|
167
|
+
if (!forceBuffer && !flushScheduled && resultBuffer.length === 0) {
|
|
168
|
+
port.postMessage(res);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
resultBuffer.push(res);
|
|
172
|
+
scheduleFlush();
|
|
173
|
+
}
|
|
174
|
+
function runJob(job) {
|
|
175
|
+
const jobId = job.jobId;
|
|
176
|
+
const inst = getInstance(job.serviceName);
|
|
177
|
+
if (!inst) {
|
|
178
|
+
postError(jobId, new Error(`Service "${job.serviceName}" is not registered`));
|
|
77
179
|
return;
|
|
78
|
-
busy = true;
|
|
79
|
-
const job = queue.shift();
|
|
80
|
-
// Set up AbortController for this job
|
|
81
|
-
const abortController = new AbortController();
|
|
82
|
-
if (job.abortSignalId) {
|
|
83
|
-
pendingAborts.set(job.abortSignalId, abortController);
|
|
84
180
|
}
|
|
85
|
-
// Inject proxy stubs
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
181
|
+
// Inject proxy stubs the first time we see a (service, propertyKey) pair.
|
|
182
|
+
// Proxies are static per service — re-mutating per job was wasted work.
|
|
183
|
+
const proxyServices = job.proxyServices;
|
|
184
|
+
if (proxyServices !== undefined && proxyServices.length > 0) {
|
|
185
|
+
for (let i = 0; i < proxyServices.length; i++) {
|
|
186
|
+
const d = proxyServices[i];
|
|
187
|
+
const key = job.serviceName + ':' + d.propertyKey;
|
|
188
|
+
if (!proxiesInstalled.has(key)) {
|
|
189
|
+
inst[d.propertyKey] = buildProxy(d);
|
|
190
|
+
proxiesInstalled.add(key);
|
|
91
191
|
}
|
|
92
192
|
}
|
|
93
193
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const inst = instances.get(job.serviceName);
|
|
99
|
-
if (!inst)
|
|
100
|
-
throw new Error(`Service "${job.serviceName}" is not registered`);
|
|
101
|
-
const fn = inst[job.methodName];
|
|
102
|
-
if (typeof fn !== 'function') {
|
|
103
|
-
throw new Error(`Task "${job.serviceName}.${job.methodName}" is not registered`);
|
|
104
|
-
}
|
|
105
|
-
// Inject AbortSignal as a last argument if the job has an abortSignalId.
|
|
106
|
-
// Call via inst.method() — not as a detached fn() — so `this` is preserved.
|
|
107
|
-
const args = job.abortSignalId
|
|
108
|
-
? [...job.args, abortController.signal]
|
|
109
|
-
: job.args;
|
|
110
|
-
return inst[job.methodName](...args);
|
|
111
|
-
};
|
|
112
|
-
try {
|
|
113
|
-
// Skip the ALS wrapper entirely when there's no context to propagate —
|
|
114
|
-
// ALS.run() has measurable overhead (async-hooks resource tracking).
|
|
115
|
-
const data = hasAls ? await workerAls.run(alsContext, run) : await run();
|
|
116
|
-
node_worker_threads_1.parentPort.postMessage({ ok: true, data });
|
|
194
|
+
const fn = inst[job.methodName];
|
|
195
|
+
if (typeof fn !== 'function') {
|
|
196
|
+
postError(jobId, new Error(`Task "${job.serviceName}.${job.methodName}" is not registered`));
|
|
197
|
+
return;
|
|
117
198
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
extra: serializeExtraProps(e),
|
|
127
|
-
};
|
|
128
|
-
node_worker_threads_1.parentPort.postMessage({ ok: false, error: serialized });
|
|
199
|
+
const abortSignalId = job.abortSignalId;
|
|
200
|
+
const args = job.args;
|
|
201
|
+
let abortController;
|
|
202
|
+
let callArgs = args;
|
|
203
|
+
if (abortSignalId !== undefined) {
|
|
204
|
+
abortController = new AbortController();
|
|
205
|
+
pendingAborts.set(abortSignalId, abortController);
|
|
206
|
+
callArgs = [...args, abortController.signal];
|
|
129
207
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
208
|
+
try {
|
|
209
|
+
const alsContext = job.alsContext;
|
|
210
|
+
// Common path: no ALS — call fn directly with `inst` as `this`.
|
|
211
|
+
let result;
|
|
212
|
+
if (alsContext === undefined) {
|
|
213
|
+
// .apply is faster than spread when callArgs is the original array,
|
|
214
|
+
// and avoids an allocation on the no-abort path.
|
|
215
|
+
result = fn.apply(inst, callArgs);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
result = workerAls.run(alsContext, () => fn.apply(inst, callArgs));
|
|
133
219
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
220
|
+
// Sync fast path: avoid Promise allocation + microtask roundtrip when
|
|
221
|
+
// the task returned a plain value.
|
|
222
|
+
if (result === null ||
|
|
223
|
+
typeof result !== 'object' ||
|
|
224
|
+
typeof result.then !== 'function') {
|
|
225
|
+
if (abortSignalId !== undefined)
|
|
226
|
+
pendingAborts.delete(abortSignalId);
|
|
227
|
+
postResult({ type: 'result', ok: true, data: result, jobId });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
result.then((data) => {
|
|
231
|
+
if (abortSignalId !== undefined)
|
|
232
|
+
pendingAborts.delete(abortSignalId);
|
|
233
|
+
postResult({ type: 'result', ok: true, data, jobId });
|
|
234
|
+
}, (error) => {
|
|
235
|
+
if (abortSignalId !== undefined)
|
|
236
|
+
pendingAborts.delete(abortSignalId);
|
|
237
|
+
postError(jobId, error);
|
|
238
|
+
});
|
|
137
239
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
for (const _k in obj) {
|
|
143
|
-
void _k;
|
|
144
|
-
return true;
|
|
240
|
+
catch (error) {
|
|
241
|
+
if (abortSignalId !== undefined)
|
|
242
|
+
pendingAborts.delete(abortSignalId);
|
|
243
|
+
postError(jobId, error);
|
|
145
244
|
}
|
|
146
|
-
|
|
245
|
+
}
|
|
246
|
+
function postError(jobId, error) {
|
|
247
|
+
const e = error;
|
|
248
|
+
const serialized = {
|
|
249
|
+
name: e?.name ?? 'Error',
|
|
250
|
+
message: e?.message ?? String(error),
|
|
251
|
+
stack: e?.stack,
|
|
252
|
+
code: e?.code,
|
|
253
|
+
extra: serializeExtraProps(e),
|
|
254
|
+
};
|
|
255
|
+
postResult({ type: 'result', ok: false, error: serialized, jobId });
|
|
147
256
|
}
|
|
148
257
|
function serializeExtraProps(err) {
|
|
149
|
-
|
|
258
|
+
if (!err || typeof err !== 'object')
|
|
259
|
+
return undefined;
|
|
260
|
+
const skip = SKIP_ERR_KEYS;
|
|
150
261
|
const extra = {};
|
|
151
262
|
let hasExtra = false;
|
|
152
263
|
for (const key of Object.keys(err)) {
|
|
@@ -162,4 +273,5 @@ function serializeExtraProps(err) {
|
|
|
162
273
|
}
|
|
163
274
|
return hasExtra ? extra : undefined;
|
|
164
275
|
}
|
|
276
|
+
const SKIP_ERR_KEYS = new Set(['name', 'message', 'stack', 'code']);
|
|
165
277
|
//# sourceMappingURL=worker-runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../../src/worker/worker-runtime.ts"],"names":[],"mappings":";;AAAA,6DAA6D;AAC7D,uDAAqD;AACrD,6DAAyD;
|
|
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;AAIxC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;AACrD,yEAAyE;AACzE,uEAAuE;AACvE,2EAA2E;AAC3E,qEAAqE;AACrE,uEAAuE;AACvE,yEAAyE;AACzE,sDAAsD;AACtD,MAAM,cAAc,GAAG,IAAI,GAAG,EAA6B,CAAC;AAC5D,KAAK,MAAM,GAAG,IAAI,QAAQ;IAAE,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE9D,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,IAAI,GAAG,SAAS,CAAC,GAAG,CAAkB,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uEAAuE;AACvE,yEAAyE;AACzE,MAAM,IAAI,GAAG,gCAAW,CAAC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,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.4",
|
|
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",
|