nestworker 2.0.4 → 2.1.0
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 +333 -134
- package/dist/core/worker.interfaces.d.ts +89 -10
- package/dist/core/worker.module.d.ts +21 -11
- package/dist/core/worker.module.js +38 -10
- package/dist/core/worker.module.js.map +1 -1
- package/dist/core/worker.pool.d.ts +26 -6
- package/dist/core/worker.pool.js +246 -101
- package/dist/core/worker.pool.js.map +1 -1
- package/dist/core/worker.service.d.ts +29 -76
- package/dist/core/worker.service.js +108 -80
- package/dist/core/worker.service.js.map +1 -1
- package/dist/decorators/worker-task.decorator.d.ts +7 -25
- package/dist/decorators/worker-task.decorator.js +5 -26
- package/dist/decorators/worker-task.decorator.js.map +1 -1
- package/dist/di/di-serializer.d.ts +9 -8
- package/dist/di/di-serializer.js +69 -46
- package/dist/di/di-serializer.js.map +1 -1
- package/dist/di/worker-container.d.ts +32 -30
- package/dist/di/worker-container.js +130 -70
- package/dist/di/worker-container.js.map +1 -1
- package/dist/discovery/discovery.service.d.ts +2 -9
- package/dist/discovery/discovery.service.js +86 -21
- package/dist/discovery/discovery.service.js.map +1 -1
- package/dist/example/image.service.d.ts +4 -0
- package/dist/example/image.service.js +16 -1
- package/dist/example/image.service.js.map +1 -1
- package/dist/example/main.js +15 -2
- package/dist/example/main.js.map +1 -1
- package/dist/health/worker.health.d.ts +46 -0
- package/dist/health/worker.health.js +77 -0
- package/dist/health/worker.health.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/worker.metrics.d.ts +65 -0
- package/dist/metrics/worker.metrics.js +122 -0
- package/dist/metrics/worker.metrics.js.map +1 -0
- package/dist/worker/worker-runtime.js +124 -27
- package/dist/worker/worker-runtime.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,123 +11,151 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
var WorkerService_1;
|
|
14
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
19
|
exports.WorkerService = void 0;
|
|
16
20
|
const common_1 = require("@nestjs/common");
|
|
21
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
17
22
|
const worker_pool_1 = require("./worker.pool");
|
|
18
23
|
const discovery_service_1 = require("../discovery/discovery.service");
|
|
19
24
|
const di_serializer_1 = require("../di/di-serializer");
|
|
20
|
-
|
|
21
|
-
* WorkerService
|
|
22
|
-
*
|
|
23
|
-
* Main entry point for executing worker-thread tasks.
|
|
24
|
-
*
|
|
25
|
-
* Features:
|
|
26
|
-
* - Lazy worker pool initialization
|
|
27
|
-
* - Automatic worker discovery
|
|
28
|
-
* - Priority queue support
|
|
29
|
-
* - Timeout support
|
|
30
|
-
* - Worker thread execution
|
|
31
|
-
* - NestJS dependency integration
|
|
32
|
-
*
|
|
33
|
-
* Lifecycle:
|
|
34
|
-
* 1. Discovers worker-enabled services
|
|
35
|
-
* 2. Serializes metadata for worker runtime
|
|
36
|
-
* 3. Creates WorkerPool
|
|
37
|
-
* 4. Dispatches tasks to workers
|
|
38
|
-
* 5. Handles graceful shutdown
|
|
39
|
-
*
|
|
40
|
-
* Example:
|
|
41
|
-
*
|
|
42
|
-
* ```ts
|
|
43
|
-
* await workerService.run(
|
|
44
|
-
* 'ImageService',
|
|
45
|
-
* 'resizeImage',
|
|
46
|
-
* [500],
|
|
47
|
-
* {
|
|
48
|
-
* priority: 'HIGH',
|
|
49
|
-
* timeout: 5000,
|
|
50
|
-
* },
|
|
51
|
-
* );
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
let WorkerService = class WorkerService {
|
|
25
|
+
let WorkerService = WorkerService_1 = class WorkerService {
|
|
55
26
|
discovery;
|
|
56
27
|
options;
|
|
28
|
+
logger = new common_1.Logger(WorkerService_1.name);
|
|
57
29
|
pool = null;
|
|
58
|
-
|
|
30
|
+
taskDefaults = new Map();
|
|
31
|
+
taskProxies = new Map();
|
|
59
32
|
constructor(discovery, options) {
|
|
60
33
|
this.discovery = discovery;
|
|
61
34
|
this.options = options;
|
|
62
35
|
}
|
|
36
|
+
onModuleInit() {
|
|
37
|
+
this.initPool();
|
|
38
|
+
}
|
|
63
39
|
initPool() {
|
|
64
40
|
if (this.pool)
|
|
65
41
|
return;
|
|
66
42
|
const tasks = this.discovery.scan();
|
|
43
|
+
const proxyMap = new Map();
|
|
67
44
|
for (const task of tasks) {
|
|
68
|
-
|
|
45
|
+
const key = `${task.serviceName}.${task.methodName}`;
|
|
46
|
+
this.taskDefaults.set(key, {
|
|
47
|
+
priority: task.priority,
|
|
48
|
+
timeout: task.timeout,
|
|
49
|
+
retry: task.retry,
|
|
50
|
+
retryDelay: task.retryDelay,
|
|
51
|
+
});
|
|
52
|
+
const descriptors = task.proxyInstances.map((p) => {
|
|
53
|
+
if (!proxyMap.has(p.propertyKey)) {
|
|
54
|
+
proxyMap.set(p.propertyKey, { methodNames: p.methodNames, instance: p.instance });
|
|
55
|
+
}
|
|
56
|
+
return { propertyKey: p.propertyKey, methodNames: p.methodNames };
|
|
57
|
+
});
|
|
58
|
+
this.taskProxies.set(key, descriptors);
|
|
69
59
|
}
|
|
70
60
|
const serialized = (0, di_serializer_1.serializeForWorker)(tasks);
|
|
71
|
-
|
|
61
|
+
const proxyInstances = Array.from(proxyMap.entries()).map(([propertyKey, { methodNames, instance }]) => ({ propertyKey, methodNames, instance }));
|
|
62
|
+
this.pool = new worker_pool_1.WorkerPool(serialized, proxyInstances, this.options.poolSize, this.options.shutdownTimeout);
|
|
63
|
+
// Forward pool events to logger and expose via EventEmitter
|
|
64
|
+
this.pool.on('dead', (event) => {
|
|
65
|
+
this.logger.error(`Dead letter: ${event.serviceName}.${event.methodName} ` +
|
|
66
|
+
`failed after ${event.attempts} attempt(s) — ${event.error.message}`);
|
|
67
|
+
});
|
|
68
|
+
this.pool.on('error', (err) => {
|
|
69
|
+
this.logger.error(`Worker pool error: ${err.message}`, err.stack);
|
|
70
|
+
});
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
|
-
*
|
|
73
|
+
* Run a @WorkerTask method in a worker thread.
|
|
75
74
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* -
|
|
79
|
-
*
|
|
80
|
-
* - overrides: runtime priority/timeout overrides
|
|
81
|
-
*
|
|
82
|
-
* Priority:
|
|
83
|
-
* - HIGH
|
|
84
|
-
* - NORMAL
|
|
85
|
-
* - LOW
|
|
86
|
-
*
|
|
87
|
-
* Timeout:
|
|
88
|
-
* Automatically terminates timed-out workers.
|
|
89
|
-
*
|
|
90
|
-
* Example:
|
|
91
|
-
*
|
|
92
|
-
* ```ts
|
|
93
|
-
* await workerService.run(
|
|
94
|
-
* 'ImageService',
|
|
95
|
-
* 'generateThumbnail',
|
|
96
|
-
* [1920, 1080],
|
|
97
|
-
* {
|
|
98
|
-
* priority: 'HIGH',
|
|
99
|
-
* timeout: 3000,
|
|
100
|
-
* },
|
|
101
|
-
* );
|
|
102
|
-
* ```
|
|
75
|
+
* @param serviceName Class name of the @WorkerClass provider
|
|
76
|
+
* @param methodName Method decorated with @WorkerTask
|
|
77
|
+
* @param args structuredClone-compatible arguments
|
|
78
|
+
* @param options Optional priority / timeout / retry / AbortSignal overrides
|
|
103
79
|
*/
|
|
104
|
-
run(serviceName, methodName, args = [],
|
|
105
|
-
this.initPool();
|
|
80
|
+
run(serviceName, methodName, args = [], options = {}) {
|
|
106
81
|
const key = `${serviceName}.${methodName}`;
|
|
107
|
-
const defaults = this.
|
|
108
|
-
|
|
82
|
+
const defaults = this.taskDefaults.get(key) ?? { priority: 'NORMAL' };
|
|
83
|
+
const proxyServices = this.taskProxies.get(key) ?? [];
|
|
84
|
+
// Capture ALS context from all registered storages
|
|
85
|
+
const alsContext = {};
|
|
86
|
+
for (const [i, als] of (this.options.asyncLocalStorages ?? []).entries()) {
|
|
87
|
+
const store = als.getStore();
|
|
88
|
+
if (store !== undefined)
|
|
89
|
+
alsContext[String(i)] = store;
|
|
90
|
+
}
|
|
91
|
+
// Capture OTEL trace context if available
|
|
92
|
+
const traceContext = captureTraceContext();
|
|
93
|
+
// Generate a unique signal ID if an AbortSignal was provided
|
|
94
|
+
const abortSignalId = options.signal ? node_crypto_1.default.randomUUID() : undefined;
|
|
109
95
|
return this.pool.execute({
|
|
96
|
+
jobId: node_crypto_1.default.randomUUID(),
|
|
110
97
|
serviceName,
|
|
111
98
|
methodName,
|
|
112
99
|
args,
|
|
113
|
-
priority:
|
|
114
|
-
timeout:
|
|
115
|
-
|
|
100
|
+
priority: options.priority ?? defaults.priority,
|
|
101
|
+
timeout: options.timeout ?? defaults.timeout,
|
|
102
|
+
retry: options.retry ?? defaults.retry ?? 0,
|
|
103
|
+
retryDelay: options.retryDelay ?? defaults.retryDelay ?? 0,
|
|
104
|
+
proxyServices,
|
|
105
|
+
alsContext,
|
|
106
|
+
traceContext,
|
|
107
|
+
abortSignalId,
|
|
108
|
+
}, options.signal);
|
|
109
|
+
}
|
|
110
|
+
/** Listen for dead-letter events (jobs that exhausted all retry attempts) */
|
|
111
|
+
onDead(listener) {
|
|
112
|
+
this.pool?.on('dead', listener);
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/** Listen for task lifecycle events */
|
|
116
|
+
onTaskEnd(listener) {
|
|
117
|
+
this.pool?.on('taskEnd', listener);
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
onTaskStart(listener) {
|
|
121
|
+
this.pool?.on('taskStart', listener);
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
onTaskError(listener) {
|
|
125
|
+
this.pool?.on('taskError', listener);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
/** Current pool stats — use for health checks and metrics */
|
|
129
|
+
stats() {
|
|
130
|
+
return this.pool?.stats() ?? {
|
|
131
|
+
poolSize: this.options.poolSize ?? 0,
|
|
132
|
+
idle: 0, busy: 0, queued: 0, warmingUp: 0,
|
|
133
|
+
};
|
|
116
134
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Gracefully shuts down worker pool.
|
|
119
|
-
*
|
|
120
|
-
* Called automatically by NestJS
|
|
121
|
-
* during application shutdown.
|
|
122
|
-
*/
|
|
123
135
|
async onModuleDestroy() {
|
|
124
136
|
await this.pool?.destroy();
|
|
125
137
|
}
|
|
126
138
|
};
|
|
127
139
|
exports.WorkerService = WorkerService;
|
|
128
|
-
exports.WorkerService = WorkerService = __decorate([
|
|
140
|
+
exports.WorkerService = WorkerService = WorkerService_1 = __decorate([
|
|
129
141
|
(0, common_1.Injectable)(),
|
|
130
142
|
__param(1, (0, common_1.Inject)('WORKER_OPTIONS')),
|
|
131
143
|
__metadata("design:paramtypes", [discovery_service_1.WorkerDiscoveryService, Object])
|
|
132
144
|
], WorkerService);
|
|
145
|
+
/**
|
|
146
|
+
* Capture the active OpenTelemetry trace context if @opentelemetry/api is
|
|
147
|
+
* available. Returns an empty object otherwise — no hard dependency.
|
|
148
|
+
*/
|
|
149
|
+
function captureTraceContext() {
|
|
150
|
+
try {
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
152
|
+
const api = require('@opentelemetry/api');
|
|
153
|
+
const carrier = {};
|
|
154
|
+
api.propagation.inject(api.context.active(), carrier);
|
|
155
|
+
return carrier;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
133
161
|
//# sourceMappingURL=worker.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.service.js","sourceRoot":"","sources":["../../src/core/worker.service.ts"],"names":[],"mappings":"
|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,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC;CACF,CAAA;AA3JY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAaR,WAAA,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;qCADG,0CAAsB;GAXzC,aAAa,CA2JzB;AAED;;;GAGG;AACH,SAAS,mBAAmB;IAC1B,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAGvC,CAAC;QACF,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -2,36 +2,18 @@ import 'reflect-metadata';
|
|
|
2
2
|
export declare const WORKER_CLASS_META = "worker:class";
|
|
3
3
|
export declare const WORKER_METHOD_META = "worker:method";
|
|
4
4
|
export declare const WORKER_DEPS_META = "worker:deps";
|
|
5
|
+
export declare const WORKER_PROXY_META = "worker:proxy";
|
|
5
6
|
export interface WorkerTaskOptions {
|
|
6
7
|
priority?: 'HIGH' | 'NORMAL' | 'LOW';
|
|
7
8
|
timeout?: number;
|
|
9
|
+
/** Number of additional attempts after the first failure. Default: 0. */
|
|
10
|
+
retry?: number;
|
|
11
|
+
/** Delay in ms between retry attempts. Supports exponential backoff
|
|
12
|
+
* when set as a function: (attempt) => attempt * 1000 */
|
|
13
|
+
retryDelay?: number | ((attempt: number) => number);
|
|
8
14
|
}
|
|
9
|
-
/**
|
|
10
|
-
* @WorkerClass() – marks a provider as a container of worker tasks.
|
|
11
|
-
*
|
|
12
|
-
* The discovery service scans all NestJS providers for this marker,
|
|
13
|
-
* then inspects each method for @WorkerTask().
|
|
14
|
-
*
|
|
15
|
-
* Declare any injectable deps that your @WorkerTask methods need via
|
|
16
|
-
* the `deps` option. These are resolved from the live NestJS container,
|
|
17
|
-
* serialised, and reconstructed inside each worker thread.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* @WorkerClass({ deps: [ConfigService] })
|
|
21
|
-
* export class ImageService { ... }
|
|
22
|
-
*/
|
|
23
15
|
export declare function WorkerClass(options?: {
|
|
24
16
|
deps?: (abstract new (...a: unknown[]) => unknown)[];
|
|
17
|
+
proxy?: (abstract new (...a: unknown[]) => unknown)[];
|
|
25
18
|
}): ClassDecorator;
|
|
26
|
-
/**
|
|
27
|
-
* @WorkerTask() – marks a method to be offloaded to a worker thread.
|
|
28
|
-
*
|
|
29
|
-
* The method must be pure with respect to thread-crossing:
|
|
30
|
-
* its arguments and return value must be structured-clone compatible.
|
|
31
|
-
* Any NestJS deps it needs should be declared on @WorkerClass({ deps }).
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* @WorkerTask({ priority: 'HIGH', timeout: 5000 })
|
|
35
|
-
* resizeImage(value: number): number { ... }
|
|
36
|
-
*/
|
|
37
19
|
export declare function WorkerTask(options?: WorkerTaskOptions): MethodDecorator;
|
|
@@ -1,45 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WORKER_DEPS_META = exports.WORKER_METHOD_META = exports.WORKER_CLASS_META = void 0;
|
|
3
|
+
exports.WORKER_PROXY_META = exports.WORKER_DEPS_META = exports.WORKER_METHOD_META = exports.WORKER_CLASS_META = void 0;
|
|
4
4
|
exports.WorkerClass = WorkerClass;
|
|
5
5
|
exports.WorkerTask = WorkerTask;
|
|
6
6
|
require("reflect-metadata");
|
|
7
7
|
exports.WORKER_CLASS_META = 'worker:class';
|
|
8
8
|
exports.WORKER_METHOD_META = 'worker:method';
|
|
9
9
|
exports.WORKER_DEPS_META = 'worker:deps';
|
|
10
|
-
|
|
11
|
-
* @WorkerClass() – marks a provider as a container of worker tasks.
|
|
12
|
-
*
|
|
13
|
-
* The discovery service scans all NestJS providers for this marker,
|
|
14
|
-
* then inspects each method for @WorkerTask().
|
|
15
|
-
*
|
|
16
|
-
* Declare any injectable deps that your @WorkerTask methods need via
|
|
17
|
-
* the `deps` option. These are resolved from the live NestJS container,
|
|
18
|
-
* serialised, and reconstructed inside each worker thread.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* @WorkerClass({ deps: [ConfigService] })
|
|
22
|
-
* export class ImageService { ... }
|
|
23
|
-
*/
|
|
10
|
+
exports.WORKER_PROXY_META = 'worker:proxy';
|
|
24
11
|
function WorkerClass(options = {}) {
|
|
25
12
|
return (target) => {
|
|
26
13
|
Reflect.defineMetadata(exports.WORKER_CLASS_META, true, target);
|
|
27
14
|
if (options.deps?.length) {
|
|
28
15
|
Reflect.defineMetadata(exports.WORKER_DEPS_META, options.deps, target);
|
|
29
16
|
}
|
|
17
|
+
if (options.proxy?.length) {
|
|
18
|
+
Reflect.defineMetadata(exports.WORKER_PROXY_META, options.proxy, target);
|
|
19
|
+
}
|
|
30
20
|
};
|
|
31
21
|
}
|
|
32
|
-
/**
|
|
33
|
-
* @WorkerTask() – marks a method to be offloaded to a worker thread.
|
|
34
|
-
*
|
|
35
|
-
* The method must be pure with respect to thread-crossing:
|
|
36
|
-
* its arguments and return value must be structured-clone compatible.
|
|
37
|
-
* Any NestJS deps it needs should be declared on @WorkerClass({ deps }).
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* @WorkerTask({ priority: 'HIGH', timeout: 5000 })
|
|
41
|
-
* resizeImage(value: number): number { ... }
|
|
42
|
-
*/
|
|
43
22
|
function WorkerTask(options = {}) {
|
|
44
23
|
return (target, propertyKey) => {
|
|
45
24
|
Reflect.defineMetadata(exports.WORKER_METHOD_META, options, target, propertyKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-task.decorator.js","sourceRoot":"","sources":["../../src/decorators/worker-task.decorator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"worker-task.decorator.js","sourceRoot":"","sources":["../../src/decorators/worker-task.decorator.ts"],"names":[],"mappings":";;;AAiBA,kCAeC;AAED,gCAIC;AAtCD,4BAA0B;AAEb,QAAA,iBAAiB,GAAI,cAAc,CAAC;AACpC,QAAA,kBAAkB,GAAG,eAAe,CAAC;AACrC,QAAA,gBAAgB,GAAK,aAAa,CAAC;AACnC,QAAA,iBAAiB,GAAI,cAAc,CAAC;AAYjD,SAAgB,WAAW,CACzB,UAGI,EAAE;IAEN,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,OAAO,CAAC,cAAc,CAAC,yBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,cAAc,CAAC,wBAAgB,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;YAC1B,OAAO,CAAC,cAAc,CAAC,yBAAiB,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,CAAC,cAAc,CAAC,0BAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -4,15 +4,16 @@ import type { SerializedService } from './worker-container';
|
|
|
4
4
|
* serializeForWorker – converts the live NestJS service graph into a
|
|
5
5
|
* structured-clone-safe SerializedService[] payload for workerData.
|
|
6
6
|
*
|
|
7
|
-
* KEY DESIGN DECISION:
|
|
7
|
+
* KEY DESIGN DECISION: file paths instead of class source strings.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* The previous approach extracted class source via Class.toString() and
|
|
10
|
+
* eval()'d it inside the worker. This broke on any import that TS compiled
|
|
11
|
+
* to a file-scoped alias (crypto_1, node_os_1, …) because those aliases
|
|
12
|
+
* don't exist inside a bare new Function() scope.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* no
|
|
14
|
+
* The new approach sends the absolute path to each compiled .js file.
|
|
15
|
+
* WorkerContainer runs each file in a vm context with a custom require()
|
|
16
|
+
* that stubs NestJS packages (so decorator calls at file-eval time are
|
|
17
|
+
* silent no-ops) while letting all other imports resolve normally.
|
|
17
18
|
*/
|
|
18
19
|
export declare function serializeForWorker(tasks: DiscoveredTask[]): SerializedService[];
|
package/dist/di/di-serializer.js
CHANGED
|
@@ -6,16 +6,17 @@ const worker_task_decorator_1 = require("../decorators/worker-task.decorator");
|
|
|
6
6
|
* serializeForWorker – converts the live NestJS service graph into a
|
|
7
7
|
* structured-clone-safe SerializedService[] payload for workerData.
|
|
8
8
|
*
|
|
9
|
-
* KEY DESIGN DECISION:
|
|
9
|
+
* KEY DESIGN DECISION: file paths instead of class source strings.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The previous approach extracted class source via Class.toString() and
|
|
12
|
+
* eval()'d it inside the worker. This broke on any import that TS compiled
|
|
13
|
+
* to a file-scoped alias (crypto_1, node_os_1, …) because those aliases
|
|
14
|
+
* don't exist inside a bare new Function() scope.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* no
|
|
16
|
+
* The new approach sends the absolute path to each compiled .js file.
|
|
17
|
+
* WorkerContainer runs each file in a vm context with a custom require()
|
|
18
|
+
* that stubs NestJS packages (so decorator calls at file-eval time are
|
|
19
|
+
* silent no-ops) while letting all other imports resolve normally.
|
|
19
20
|
*/
|
|
20
21
|
function serializeForWorker(tasks) {
|
|
21
22
|
const byService = new Map();
|
|
@@ -31,21 +32,32 @@ function serializeForWorker(tasks) {
|
|
|
31
32
|
}
|
|
32
33
|
const result = [];
|
|
33
34
|
for (const [serviceName, { representative, methods }] of byService) {
|
|
34
|
-
const { metatype, instance
|
|
35
|
+
const { metatype, instance } = representative;
|
|
35
36
|
const depTypes = Reflect.getMetadata(worker_task_decorator_1.WORKER_DEPS_META, metatype) ?? [];
|
|
36
|
-
const serializedDeps = depTypes.map((DepType
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const serializedDeps = depTypes.map((DepType) => {
|
|
38
|
+
// Derive the property key from the class name first as a candidate,
|
|
39
|
+
// then verify by looking at the live instance's own properties.
|
|
40
|
+
// We read the dep instance DIRECTLY from the service instance's property
|
|
41
|
+
// rather than from moduleRef.get() — this avoids the NestJS Proxy
|
|
42
|
+
// mismatch where moduleRef returns the real instance but the service
|
|
43
|
+
// holds a lazy Proxy wrapper (different references, same underlying object).
|
|
44
|
+
const candidateKey = camelCase(DepType.name);
|
|
45
|
+
const propertyKey = findDepPropertyKey(instance, DepType) ?? candidateKey;
|
|
46
|
+
// Always read the dep from the live service instance by property key —
|
|
47
|
+
// this gives us the exact object the service will use at runtime,
|
|
48
|
+
// including any NestJS Proxy wrapper, so snapshot captures real state.
|
|
49
|
+
const depInstance = instance[propertyKey] ??
|
|
50
|
+
instance[candidateKey];
|
|
39
51
|
return {
|
|
40
52
|
name: DepType.name,
|
|
41
|
-
|
|
53
|
+
filePath: findFilePath(DepType),
|
|
42
54
|
snapshot: snapshotInstance(depInstance),
|
|
43
|
-
propertyKey,
|
|
55
|
+
propertyKey: propertyKey ?? candidateKey,
|
|
44
56
|
};
|
|
45
57
|
});
|
|
46
58
|
result.push({
|
|
47
59
|
name: serviceName,
|
|
48
|
-
|
|
60
|
+
filePath: findFilePath(metatype),
|
|
49
61
|
methods,
|
|
50
62
|
deps: serializedDeps,
|
|
51
63
|
});
|
|
@@ -53,38 +65,43 @@ function serializeForWorker(tasks) {
|
|
|
53
65
|
return result;
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* returns the full class body including all methods — but WITHOUT the
|
|
60
|
-
* import statements or decorator calls at the top of the file.
|
|
61
|
-
*
|
|
62
|
-
* Example output:
|
|
63
|
-
* "class ConfigService {
|
|
64
|
-
* constructor() { this.config = { MULTIPLIER: '3' }; }
|
|
65
|
-
* get(k) { return this.config[k]; }
|
|
66
|
-
* getNumber(k) { return Number(this.config[k]); }
|
|
67
|
-
* }"
|
|
68
|
-
*
|
|
69
|
-
* This is eval()-safe and has no NestJS dependencies.
|
|
68
|
+
* Locate the compiled .js file for this constructor by scanning require.cache.
|
|
69
|
+
* NestJS loads all providers via require() so every user-defined class will
|
|
70
|
+
* be present in the cache at the time serializeForWorker() is called.
|
|
70
71
|
*/
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
function findFilePath(ctor) {
|
|
73
|
+
for (const [filePath, mod] of Object.entries(require.cache)) {
|
|
74
|
+
if (!mod?.exports || typeof mod.exports !== 'object')
|
|
75
|
+
continue;
|
|
76
|
+
// Object.values() triggers getters on prototype-based exports (e.g. Express
|
|
77
|
+
// IncomingMessage.protocol accesses this.socket which is undefined at scan
|
|
78
|
+
// time). Iterate keys manually and guard each access with try/catch.
|
|
79
|
+
for (const key of Object.keys(mod.exports)) {
|
|
80
|
+
// Skip getters entirely — accessing them may trigger deprecation warnings
|
|
81
|
+
// (e.g. Express req.host) or throw (e.g. IncomingMessage.protocol).
|
|
82
|
+
// Constructors are always plain value exports, never getters.
|
|
83
|
+
const desc = Object.getOwnPropertyDescriptor(mod.exports, key);
|
|
84
|
+
if (!desc || typeof desc.get === 'function')
|
|
85
|
+
continue;
|
|
86
|
+
if (desc.value === ctor)
|
|
87
|
+
return filePath;
|
|
88
|
+
}
|
|
80
89
|
}
|
|
81
|
-
|
|
90
|
+
throw new Error(`nestworker: could not find compiled file for "${ctor.name}" in require.cache. ` +
|
|
91
|
+
`Ensure the class is exported from its module file and the project is ` +
|
|
92
|
+
`compiled (not running via ts-node) before starting.`);
|
|
82
93
|
}
|
|
83
|
-
function findDepPropertyKey(serviceInstance,
|
|
94
|
+
function findDepPropertyKey(serviceInstance, DepType) {
|
|
84
95
|
if (!serviceInstance || typeof serviceInstance !== 'object')
|
|
85
96
|
return undefined;
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
// private readonly fields are non-enumerable — must use getOwnPropertyNames().
|
|
98
|
+
// We match by constructor type rather than reference equality to correctly
|
|
99
|
+
// handle NestJS Proxy wrappers: the service may hold a Proxy of the dep
|
|
100
|
+
// while moduleRef.get() returns the unwrapped instance — different refs,
|
|
101
|
+
// same underlying class. instanceof sees through Proxy transparently.
|
|
102
|
+
for (const key of Object.getOwnPropertyNames(serviceInstance)) {
|
|
103
|
+
const val = serviceInstance[key];
|
|
104
|
+
if (val instanceof DepType)
|
|
88
105
|
return key;
|
|
89
106
|
}
|
|
90
107
|
return undefined;
|
|
@@ -93,14 +110,20 @@ function snapshotInstance(instance) {
|
|
|
93
110
|
if (!instance || typeof instance !== 'object')
|
|
94
111
|
return {};
|
|
95
112
|
const out = {};
|
|
96
|
-
|
|
113
|
+
// private readonly fields are non-enumerable — must use getOwnPropertyNames()
|
|
114
|
+
for (const k of Object.getOwnPropertyNames(instance)) {
|
|
115
|
+
const v = instance[k];
|
|
97
116
|
if (typeof v === 'function' || typeof v === 'symbol')
|
|
98
117
|
continue;
|
|
99
118
|
try {
|
|
100
|
-
|
|
101
|
-
|
|
119
|
+
// Store the CLONED value, not the original reference.
|
|
120
|
+
// structuredClone succeeds for plain outer objects even when they
|
|
121
|
+
// contain non-cloneable internal slots nested deeply — in that case
|
|
122
|
+
// storing `v` would pass a live socket/stream reference into workerData,
|
|
123
|
+
// producing broken objects with missing internal state in the worker.
|
|
124
|
+
out[k] = structuredClone(v);
|
|
102
125
|
}
|
|
103
|
-
catch { /* skip non-cloneable */ }
|
|
126
|
+
catch { /* skip non-cloneable values entirely */ }
|
|
104
127
|
}
|
|
105
128
|
return out;
|
|
106
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"di-serializer.js","sourceRoot":"","sources":["../../src/di/di-serializer.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"di-serializer.js","sourceRoot":"","sources":["../../src/di/di-serializer.ts"],"names":[],"mappings":";;AAoBA,gDA2DC;AA7ED,+EAAuE;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,kBAAkB,CAAC,KAAuB;IACxD,MAAM,SAAS,GAAG,IAAI,GAAG,EAGtB,CAAC;IAEJ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAE,CAAC,OAAO,CAAC,IAAI,CAAC;YAC5C,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,KAAK,MAAM,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACnE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QAE9C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