callman-core 1.25.0 → 1.26.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/dist/contract/contractValidator.d.ts.map +1 -1
- package/dist/contract/contractValidator.js +13 -4
- package/dist/contract/contractValidator.js.map +1 -1
- package/dist/host/db/mysqlAdapter.d.ts.map +1 -1
- package/dist/host/db/mysqlAdapter.js +39 -9
- package/dist/host/db/mysqlAdapter.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/request/executeRequest.d.ts +1 -1
- package/dist/request/executeRequest.d.ts.map +1 -1
- package/dist/request/executeRequest.js +8 -1
- package/dist/request/executeRequest.js.map +1 -1
- package/dist/runner/runCollection.d.ts.map +1 -1
- package/dist/runner/runCollection.js +8 -3
- package/dist/runner/runCollection.js.map +1 -1
- package/dist/scenario-runner/adapters/request-executor.js +12 -3
- package/dist/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist/scenario-runner/adapters/script-executor.js +1 -1
- package/dist/scenario-runner/adapters/script-executor.js.map +1 -1
- package/dist/scenario-runner/adapters/types.d.ts +1 -0
- package/dist/scenario-runner/adapters/types.d.ts.map +1 -1
- package/dist/scenario-runner/boundSnapshot.d.ts +15 -0
- package/dist/scenario-runner/boundSnapshot.d.ts.map +1 -0
- package/dist/scenario-runner/boundSnapshot.js +67 -0
- package/dist/scenario-runner/boundSnapshot.js.map +1 -0
- package/dist/scenario-runner/runScenario.d.ts +1 -1
- package/dist/scenario-runner/runScenario.d.ts.map +1 -1
- package/dist/scenario-runner/runScenario.js +42 -25
- package/dist/scenario-runner/runScenario.js.map +1 -1
- package/dist/scenario-runner/runScenarioWithDataset.d.ts.map +1 -1
- package/dist/scenario-runner/runScenarioWithDataset.js +21 -6
- package/dist/scenario-runner/runScenarioWithDataset.js.map +1 -1
- package/dist/scenario-runner/types.d.ts +10 -0
- package/dist/scenario-runner/types.d.ts.map +1 -1
- package/dist/script/isolated-runner.d.ts +7 -1
- package/dist/script/isolated-runner.d.ts.map +1 -1
- package/dist/script/isolated-runner.js +11 -5
- package/dist/script/isolated-runner.js.map +1 -1
- package/dist/script/worker-entry.js +62 -28
- package/dist/script/worker-entry.js.map +1 -1
- package/dist/script/worker-pool.d.ts +60 -0
- package/dist/script/worker-pool.d.ts.map +1 -0
- package/dist/script/worker-pool.js +274 -0
- package/dist/script/worker-pool.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist-cjs/contract/contractValidator.js +13 -4
- package/dist-cjs/contract/contractValidator.js.map +1 -1
- package/dist-cjs/host/db/mysqlAdapter.js +39 -9
- package/dist-cjs/host/db/mysqlAdapter.js.map +1 -1
- package/dist-cjs/index.js +4 -1
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/request/executeRequest.js +8 -1
- package/dist-cjs/request/executeRequest.js.map +1 -1
- package/dist-cjs/runner/runCollection.js +8 -3
- package/dist-cjs/runner/runCollection.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/request-executor.js +12 -3
- package/dist-cjs/scenario-runner/adapters/request-executor.js.map +1 -1
- package/dist-cjs/scenario-runner/adapters/script-executor.js +1 -1
- package/dist-cjs/scenario-runner/adapters/script-executor.js.map +1 -1
- package/dist-cjs/scenario-runner/boundSnapshot.js +71 -0
- package/dist-cjs/scenario-runner/boundSnapshot.js.map +1 -0
- package/dist-cjs/scenario-runner/runScenario.js +42 -25
- package/dist-cjs/scenario-runner/runScenario.js.map +1 -1
- package/dist-cjs/scenario-runner/runScenarioWithDataset.js +21 -6
- package/dist-cjs/scenario-runner/runScenarioWithDataset.js.map +1 -1
- package/dist-cjs/script/isolated-runner.js +12 -5
- package/dist-cjs/script/isolated-runner.js.map +1 -1
- package/dist-cjs/script/worker-entry.js +62 -28
- package/dist-cjs/script/worker-entry.js.map +1 -1
- package/dist-cjs/script/worker-pool.js +312 -0
- package/dist-cjs/script/worker-pool.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// worker_threads entry for runScriptIsolated. Runs the
|
|
3
|
-
// inside the worker so a runaway/CPU-bound user
|
|
4
|
-
// thread — the host hard-kills it via
|
|
2
|
+
// worker_threads entry for runScriptIsolated / ScriptWorkerPool. Runs the
|
|
3
|
+
// canonical executeScript inside the worker so a runaway/CPU-bound user
|
|
4
|
+
// script blocks only this worker thread — the host hard-kills it via
|
|
5
|
+
// worker.terminate() on timeout.
|
|
6
|
+
//
|
|
7
|
+
// Two modes, selected by `workerData`:
|
|
8
|
+
// • one-shot — `workerData.input` is the script; run it, post "done", exit.
|
|
9
|
+
// • pool — `workerData.mode === "pool"`: stay alive and run every
|
|
10
|
+
// `{ type: "run", taskId, input }` message the host posts,
|
|
11
|
+
// answering `{ type: "done", taskId, result }` (worker-pool.ts).
|
|
5
12
|
//
|
|
6
13
|
// pm.sendRequest (when the host enabled it) is proxied back to the host over
|
|
7
14
|
// the MessagePort: each call posts a "sendRequest" message and awaits the
|
|
@@ -22,9 +29,26 @@ const jsonSafe = (value) => {
|
|
|
22
29
|
return null;
|
|
23
30
|
}
|
|
24
31
|
};
|
|
32
|
+
const failureResult = (input, error) => ({
|
|
33
|
+
success: false,
|
|
34
|
+
error: {
|
|
35
|
+
stage: input.stage ?? "script",
|
|
36
|
+
message: error instanceof Error ? error.message : String(error),
|
|
37
|
+
lineNumber: null,
|
|
38
|
+
column: null,
|
|
39
|
+
stack: error instanceof Error ? (error.stack ?? null) : null,
|
|
40
|
+
},
|
|
41
|
+
testResults: [],
|
|
42
|
+
variableMutations: [],
|
|
43
|
+
logs: [],
|
|
44
|
+
hasReturnValue: false,
|
|
45
|
+
});
|
|
25
46
|
if (port) {
|
|
26
47
|
const pendingSendRequests = new Map();
|
|
27
48
|
let nextRequestId = 1;
|
|
49
|
+
// Pool mode: the task the current script belongs to, so the host can match
|
|
50
|
+
// sendRequest round-trips and completion to it.
|
|
51
|
+
let currentTaskId = null;
|
|
28
52
|
port.on("message", (message) => {
|
|
29
53
|
if (message.type === "sendRequestResult") {
|
|
30
54
|
const pending = pendingSendRequests.get(message.id);
|
|
@@ -43,39 +67,49 @@ if (port) {
|
|
|
43
67
|
const sendRequestProxy = (input) => new Promise((resolve, reject) => {
|
|
44
68
|
const id = nextRequestId++;
|
|
45
69
|
pendingSendRequests.set(id, { resolve, reject });
|
|
46
|
-
port.postMessage({ type: "sendRequest", id, input });
|
|
70
|
+
port.postMessage({ type: "sendRequest", id, input, taskId: currentTaskId });
|
|
47
71
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
const runOne = async (input, enableSendRequest) => {
|
|
73
|
+
if (enableSendRequest) {
|
|
74
|
+
input.capabilities.extensions = {
|
|
75
|
+
...(input.capabilities.extensions ?? {}),
|
|
76
|
+
sendRequest: { execute: sendRequestProxy },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
55
79
|
let result;
|
|
56
80
|
try {
|
|
57
|
-
result = await (0, executor_js_1.executeScript)(
|
|
81
|
+
result = await (0, executor_js_1.executeScript)(input);
|
|
58
82
|
}
|
|
59
83
|
catch (error) {
|
|
60
|
-
result =
|
|
61
|
-
success: false,
|
|
62
|
-
error: {
|
|
63
|
-
stage: data.input.stage ?? "script",
|
|
64
|
-
message: error instanceof Error ? error.message : String(error),
|
|
65
|
-
lineNumber: null,
|
|
66
|
-
column: null,
|
|
67
|
-
stack: error instanceof Error ? (error.stack ?? null) : null,
|
|
68
|
-
},
|
|
69
|
-
testResults: [],
|
|
70
|
-
variableMutations: [],
|
|
71
|
-
logs: [],
|
|
72
|
-
hasReturnValue: false,
|
|
73
|
-
};
|
|
84
|
+
result = failureResult(input, error);
|
|
74
85
|
}
|
|
75
86
|
if (result.hasReturnValue) {
|
|
76
87
|
result = { ...result, returnValue: jsonSafe(result.returnValue) };
|
|
77
88
|
}
|
|
78
|
-
|
|
79
|
-
}
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
if ("mode" in data && data.mode === "pool") {
|
|
92
|
+
port.on("message", (message) => {
|
|
93
|
+
if (message.type !== "run") {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const taskId = message.taskId;
|
|
97
|
+
currentTaskId = taskId;
|
|
98
|
+
// A previous task's unanswered sendRequests can never be resolved now.
|
|
99
|
+
pendingSendRequests.clear();
|
|
100
|
+
void runOne(message.input, Boolean(message.enableSendRequest)).then((result) => {
|
|
101
|
+
if (currentTaskId === taskId) {
|
|
102
|
+
currentTaskId = null;
|
|
103
|
+
}
|
|
104
|
+
port.postMessage({ type: "done", taskId, result });
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const oneShot = data;
|
|
110
|
+
void runOne(oneShot.input, oneShot.enableSendRequest).then((result) => {
|
|
111
|
+
port.postMessage({ type: "done", result });
|
|
112
|
+
});
|
|
113
|
+
}
|
|
80
114
|
}
|
|
81
115
|
//# sourceMappingURL=worker-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-entry.js","sourceRoot":"","sources":["../../src/script/worker-entry.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"worker-entry.js","sourceRoot":"","sources":["../../src/script/worker-entry.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,wEAAwE;AACxE,qEAAqE;AACrE,iCAAiC;AACjC,EAAE;AACF,uCAAuC;AACvC,+EAA+E;AAC/E,yEAAyE;AACzE,2EAA2E;AAC3E,iFAAiF;AACjF,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,sCAAsC;;AAEtC,6DAA6D;AAE7D,+CAA8C;AAa9C,MAAM,IAAI,GAAG,gCAAU,CAAC;AACxB,MAAM,IAAI,GAAG,gCAAgD,CAAC;AAE9D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,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Reusable worker_threads pool for `runScriptIsolated`.
|
|
3
|
+
//
|
|
4
|
+
// The one-shot path in isolated-runner.ts spawns a fresh Worker (a whole V8
|
|
5
|
+
// isolate: ~10-15 MB and a few tens of ms to boot the script bundle) for
|
|
6
|
+
// EVERY script execution. A scenario worker running 20-50 scenarios with
|
|
7
|
+
// pre-request / tests / script nodes therefore churned isolates
|
|
8
|
+
// continuously and, with no `resourceLimits`, let a memory-hungry script
|
|
9
|
+
// grow past the pod's limit. This pool keeps N warm workers, hands each
|
|
10
|
+
// script to an idle one, and:
|
|
11
|
+
// • caps every worker's heap via `resourceLimits` — a runaway script hits
|
|
12
|
+
// the WORKER's limit (a clean "worker crashed" result) instead of the
|
|
13
|
+
// host process's;
|
|
14
|
+
// • hard-kills (terminate + respawn) a worker whose script exceeds its
|
|
15
|
+
// timeout or is aborted, exactly like the one-shot path;
|
|
16
|
+
// • queues excess scripts FIFO instead of spawning more isolates.
|
|
17
|
+
//
|
|
18
|
+
// Node-only. `node:worker_threads` / `node:path` are imported lazily (see the
|
|
19
|
+
// note in isolated-runner.ts): the barrel re-exports the factory, so this
|
|
20
|
+
// module is pulled into the renderer bundle and must not touch node builtins
|
|
21
|
+
// at module-eval time. `createScriptWorkerPool` returns `null` outside the
|
|
22
|
+
// CJS Node build (no `__dirname`), and callers fall back to the one-shot
|
|
23
|
+
// runner.
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
+
}) : function(o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
41
|
+
var ownKeys = function(o) {
|
|
42
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
43
|
+
var ar = [];
|
|
44
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
45
|
+
return ar;
|
|
46
|
+
};
|
|
47
|
+
return ownKeys(o);
|
|
48
|
+
};
|
|
49
|
+
return function (mod) {
|
|
50
|
+
if (mod && mod.__esModule) return mod;
|
|
51
|
+
var result = {};
|
|
52
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
53
|
+
__setModuleDefault(result, mod);
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
})();
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
exports.createScriptWorkerPool = exports.ScriptWorkerPool = void 0;
|
|
59
|
+
const errors_js_1 = require("./errors.js");
|
|
60
|
+
const DEFAULT_SIZE = 2;
|
|
61
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
62
|
+
const DEFAULT_HARD_KILL_MARGIN_MS = 2_000;
|
|
63
|
+
const DEFAULT_RESOURCE_LIMITS = {
|
|
64
|
+
maxOldGenerationSizeMb: 128,
|
|
65
|
+
maxYoungGenerationSizeMb: 32,
|
|
66
|
+
stackSizeMb: 4,
|
|
67
|
+
};
|
|
68
|
+
const terminalResult = (input, message, error) => ({
|
|
69
|
+
success: false,
|
|
70
|
+
error: typeof error !== "undefined"
|
|
71
|
+
? (0, errors_js_1.toSerializableError)(input.stage ?? "script", error)
|
|
72
|
+
: { stage: input.stage ?? "script", message, lineNumber: null, column: null, stack: null },
|
|
73
|
+
testResults: [],
|
|
74
|
+
variableMutations: [],
|
|
75
|
+
logs: [],
|
|
76
|
+
hasReturnValue: false,
|
|
77
|
+
});
|
|
78
|
+
class ScriptWorkerPool {
|
|
79
|
+
workerPath;
|
|
80
|
+
loadWorkerThreads;
|
|
81
|
+
size;
|
|
82
|
+
resourceLimits;
|
|
83
|
+
hardKillMarginMs;
|
|
84
|
+
workers = new Set();
|
|
85
|
+
idle = [];
|
|
86
|
+
queue = [];
|
|
87
|
+
// Workers whose `spawn()` is still awaiting the lazy worker_threads import.
|
|
88
|
+
// Counted against `size` so concurrent `dispatch()` calls (one per `run`)
|
|
89
|
+
// cannot all pass the capacity check before the first thread exists.
|
|
90
|
+
spawning = 0;
|
|
91
|
+
nextTaskId = 1;
|
|
92
|
+
closed = false;
|
|
93
|
+
constructor(workerPath, loadWorkerThreads, options = {}) {
|
|
94
|
+
this.workerPath = workerPath;
|
|
95
|
+
this.loadWorkerThreads = loadWorkerThreads;
|
|
96
|
+
this.size = Math.max(1, Math.floor(options.size ?? DEFAULT_SIZE));
|
|
97
|
+
this.resourceLimits = { ...DEFAULT_RESOURCE_LIMITS, ...(options.resourceLimits ?? {}) };
|
|
98
|
+
this.hardKillMarginMs = options.hardKillMarginMs ?? DEFAULT_HARD_KILL_MARGIN_MS;
|
|
99
|
+
}
|
|
100
|
+
/** Scripts currently executing + waiting — for metrics / tests. */
|
|
101
|
+
get stats() {
|
|
102
|
+
return { workers: this.workers.size, idle: this.idle.length, queued: this.queue.length };
|
|
103
|
+
}
|
|
104
|
+
run(input, options = {}) {
|
|
105
|
+
if (this.closed) {
|
|
106
|
+
return Promise.resolve(terminalResult(input, "Script worker pool is closed"));
|
|
107
|
+
}
|
|
108
|
+
if (options.signal?.aborted) {
|
|
109
|
+
return Promise.resolve(terminalResult(input, "Script execution aborted"));
|
|
110
|
+
}
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
const task = { id: this.nextTaskId++, input, options, resolve, settled: false };
|
|
113
|
+
this.queue.push(task);
|
|
114
|
+
void this.dispatch();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async close() {
|
|
118
|
+
this.closed = true;
|
|
119
|
+
for (const task of this.queue.splice(0)) {
|
|
120
|
+
this.settle(task, terminalResult(task.input, "Script worker pool is closed"));
|
|
121
|
+
}
|
|
122
|
+
const all = [...this.workers];
|
|
123
|
+
this.workers.clear();
|
|
124
|
+
this.idle.length = 0;
|
|
125
|
+
await Promise.all(all.map(async (worker) => {
|
|
126
|
+
if (worker.busy) {
|
|
127
|
+
this.settle(worker.busy, terminalResult(worker.busy.input, "Script worker pool is closed"));
|
|
128
|
+
this.clearTaskTimers(worker);
|
|
129
|
+
}
|
|
130
|
+
await worker.thread.terminate().catch(() => undefined);
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
settle(task, result) {
|
|
134
|
+
if (task.settled)
|
|
135
|
+
return;
|
|
136
|
+
task.settled = true;
|
|
137
|
+
task.resolve(result);
|
|
138
|
+
}
|
|
139
|
+
clearTaskTimers(worker) {
|
|
140
|
+
if (worker.killTimer) {
|
|
141
|
+
clearTimeout(worker.killTimer);
|
|
142
|
+
worker.killTimer = null;
|
|
143
|
+
}
|
|
144
|
+
if (worker.abortHandler && worker.busy?.options.signal) {
|
|
145
|
+
worker.busy.options.signal.removeEventListener?.("abort", worker.abortHandler);
|
|
146
|
+
}
|
|
147
|
+
worker.abortHandler = null;
|
|
148
|
+
}
|
|
149
|
+
async dispatch() {
|
|
150
|
+
while (!this.closed && this.queue.length > 0) {
|
|
151
|
+
let worker = this.idle.pop() ?? null;
|
|
152
|
+
if (!worker) {
|
|
153
|
+
if (this.workers.size + this.spawning >= this.size) {
|
|
154
|
+
return; // every worker is busy — the next `release` re-dispatches
|
|
155
|
+
}
|
|
156
|
+
this.spawning += 1;
|
|
157
|
+
try {
|
|
158
|
+
worker = await this.spawn();
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
const task = this.queue.shift();
|
|
162
|
+
if (task)
|
|
163
|
+
this.settle(task, terminalResult(task.input, "Failed to start script worker", error));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
this.spawning -= 1;
|
|
168
|
+
}
|
|
169
|
+
if (this.closed) {
|
|
170
|
+
await worker.thread.terminate().catch(() => undefined);
|
|
171
|
+
this.workers.delete(worker);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const task = this.queue.shift();
|
|
176
|
+
if (!task) {
|
|
177
|
+
this.idle.push(worker);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.assign(worker, task);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async spawn() {
|
|
184
|
+
const { Worker } = await this.loadWorkerThreads();
|
|
185
|
+
const thread = new Worker(this.workerPath, {
|
|
186
|
+
workerData: { mode: "pool" },
|
|
187
|
+
resourceLimits: this.resourceLimits,
|
|
188
|
+
});
|
|
189
|
+
const worker = { thread, busy: null, killTimer: null, abortHandler: null };
|
|
190
|
+
this.workers.add(worker);
|
|
191
|
+
thread.on("message", (message) => {
|
|
192
|
+
const task = worker.busy;
|
|
193
|
+
if (!task || message.taskId !== task.id)
|
|
194
|
+
return;
|
|
195
|
+
if (message.type === "done") {
|
|
196
|
+
this.release(worker, message.result);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (message.type === "sendRequest") {
|
|
200
|
+
const requestId = message.id;
|
|
201
|
+
const requestInput = message.input;
|
|
202
|
+
void (async () => {
|
|
203
|
+
try {
|
|
204
|
+
if (!task.options.onSendRequest) {
|
|
205
|
+
throw new Error("pm.sendRequest is not available in this context.");
|
|
206
|
+
}
|
|
207
|
+
const result = await task.options.onSendRequest(requestInput);
|
|
208
|
+
if (worker.busy === task && !task.settled) {
|
|
209
|
+
thread.postMessage({ type: "sendRequestResult", id: requestId, ok: true, result });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
if (worker.busy === task && !task.settled) {
|
|
214
|
+
thread.postMessage({
|
|
215
|
+
type: "sendRequestResult",
|
|
216
|
+
id: requestId,
|
|
217
|
+
ok: false,
|
|
218
|
+
error: error instanceof Error ? error.message : String(error),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
thread.on("error", (error) => {
|
|
226
|
+
this.retire(worker, (task) => terminalResult(task.input, "Script worker crashed", error));
|
|
227
|
+
});
|
|
228
|
+
thread.on("exit", (code) => {
|
|
229
|
+
this.retire(worker, (task) => terminalResult(task.input, `Script worker exited unexpectedly (code ${code})`));
|
|
230
|
+
});
|
|
231
|
+
return worker;
|
|
232
|
+
}
|
|
233
|
+
assign(worker, task) {
|
|
234
|
+
worker.busy = task;
|
|
235
|
+
const timeoutMs = task.input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
236
|
+
worker.killTimer = setTimeout(() => {
|
|
237
|
+
this.kill(worker, terminalResult(task.input, `Script timed out after ${timeoutMs}ms`));
|
|
238
|
+
}, timeoutMs + this.hardKillMarginMs);
|
|
239
|
+
if (task.options.signal) {
|
|
240
|
+
worker.abortHandler = () => {
|
|
241
|
+
this.kill(worker, terminalResult(task.input, "Script execution aborted"));
|
|
242
|
+
};
|
|
243
|
+
task.options.signal.addEventListener?.("abort", worker.abortHandler, { once: true });
|
|
244
|
+
}
|
|
245
|
+
worker.thread.postMessage({
|
|
246
|
+
type: "run",
|
|
247
|
+
taskId: task.id,
|
|
248
|
+
input: task.input,
|
|
249
|
+
enableSendRequest: Boolean(task.options.onSendRequest),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/** Normal completion: settle the task and return the worker to the idle set. */
|
|
253
|
+
release(worker, result) {
|
|
254
|
+
const task = worker.busy;
|
|
255
|
+
this.clearTaskTimers(worker);
|
|
256
|
+
worker.busy = null;
|
|
257
|
+
if (task)
|
|
258
|
+
this.settle(task, result);
|
|
259
|
+
if (!this.closed && this.workers.has(worker)) {
|
|
260
|
+
this.idle.push(worker);
|
|
261
|
+
void this.dispatch();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** Timeout / abort: the script may be spinning — terminate the isolate. */
|
|
265
|
+
kill(worker, result) {
|
|
266
|
+
const task = worker.busy;
|
|
267
|
+
this.clearTaskTimers(worker);
|
|
268
|
+
worker.busy = null;
|
|
269
|
+
this.workers.delete(worker);
|
|
270
|
+
const idleIndex = this.idle.indexOf(worker);
|
|
271
|
+
if (idleIndex >= 0)
|
|
272
|
+
this.idle.splice(idleIndex, 1);
|
|
273
|
+
if (task)
|
|
274
|
+
this.settle(task, result);
|
|
275
|
+
void worker.thread.terminate().catch(() => undefined);
|
|
276
|
+
void this.dispatch();
|
|
277
|
+
}
|
|
278
|
+
/** The thread died on its own (error / exit): drop it, fail its task, refill lazily. */
|
|
279
|
+
retire(worker, describe) {
|
|
280
|
+
if (!this.workers.has(worker))
|
|
281
|
+
return;
|
|
282
|
+
const task = worker.busy;
|
|
283
|
+
this.clearTaskTimers(worker);
|
|
284
|
+
worker.busy = null;
|
|
285
|
+
this.workers.delete(worker);
|
|
286
|
+
const idleIndex = this.idle.indexOf(worker);
|
|
287
|
+
if (idleIndex >= 0)
|
|
288
|
+
this.idle.splice(idleIndex, 1);
|
|
289
|
+
if (task)
|
|
290
|
+
this.settle(task, describe(task));
|
|
291
|
+
void this.dispatch();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
exports.ScriptWorkerPool = ScriptWorkerPool;
|
|
295
|
+
/**
|
|
296
|
+
* Build a pool bound to the sibling `worker-entry.js`. Returns `null` when
|
|
297
|
+
* the module is not running from the CJS Node build (no `__dirname`) — the
|
|
298
|
+
* caller should then fall back to the one-shot `runScriptIsolated` path.
|
|
299
|
+
*/
|
|
300
|
+
const createScriptWorkerPool = (options = {}) => {
|
|
301
|
+
// eslint-disable-next-line no-eval
|
|
302
|
+
const moduleDir = eval("typeof __dirname !== 'undefined' ? __dirname : undefined");
|
|
303
|
+
if (!moduleDir) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
// Lazy node-builtin imports — only reached in the CJS Node hosts.
|
|
307
|
+
const loadWorkerThreads = () => Promise.resolve().then(() => __importStar(require("node:worker_threads")));
|
|
308
|
+
const workerPath = `${moduleDir}/worker-entry.js`;
|
|
309
|
+
return new ScriptWorkerPool(workerPath, loadWorkerThreads, options);
|
|
310
|
+
};
|
|
311
|
+
exports.createScriptWorkerPool = createScriptWorkerPool;
|
|
312
|
+
//# sourceMappingURL=worker-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-pool.js","sourceRoot":"","sources":["../../src/script/worker-pool.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,yEAAyE;AACzE,gEAAgE;AAChE,yEAAyE;AACzE,wEAAwE;AACxE,8BAA8B;AAC9B,4EAA4E;AAC5E,0EAA0E;AAC1E,sBAAsB;AACtB,yEAAyE;AACzE,6DAA6D;AAC7D,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,2EAA2E;AAC3E,yEAAyE;AACzE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEV,2CAAkD;AA8ClD,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAC1C,MAAM,uBAAuB,GAA+B;IAC1D,sBAAsB,EAAE,GAAG;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