@openfn/ws-worker 1.18.1 → 1.19.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/CHANGELOG.md +14 -0
- package/dist/index.js +8 -1
- package/dist/start.js +28 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# ws-worker
|
|
2
2
|
|
|
3
|
+
## 1.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 475f8cf: Add options to profile memory usage in workflows. This should give a more accurate reading of the memory used by a run, but may have a small impact on performance
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 34edb8b: Improved logging of available memory on claim
|
|
12
|
+
- Updated dependencies [3cd3cd5]
|
|
13
|
+
- Updated dependencies [475f8cf]
|
|
14
|
+
- @openfn/runtime@1.7.4
|
|
15
|
+
- @openfn/engine-multi@1.8.0
|
|
16
|
+
|
|
3
17
|
## 1.18.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -120,6 +120,7 @@ var tryWithBackoff = (fn, opts = {}) => {
|
|
|
120
120
|
var try_with_backoff_default = tryWithBackoff;
|
|
121
121
|
|
|
122
122
|
// src/api/claim.ts
|
|
123
|
+
import v8 from "node:v8";
|
|
123
124
|
import * as Sentry from "@sentry/node";
|
|
124
125
|
import crypto from "node:crypto";
|
|
125
126
|
import * as jose from "jose";
|
|
@@ -177,7 +178,13 @@ var claim = (app, logger = mockLogger, options = {}) => {
|
|
|
177
178
|
}
|
|
178
179
|
const claimId = ++claimIdGen;
|
|
179
180
|
app.openClaims[claimId] = demand;
|
|
180
|
-
|
|
181
|
+
const { used_heap_size, heap_size_limit } = v8.getHeapStatistics();
|
|
182
|
+
const usedHeapMb = Math.round(used_heap_size / 1024 / 1024);
|
|
183
|
+
const totalHeapMb = Math.round(heap_size_limit / 1024 / 1024);
|
|
184
|
+
const memPercent = Math.round(usedHeapMb / totalHeapMb * 100);
|
|
185
|
+
logger.debug(
|
|
186
|
+
`Claiming runs :: demand ${demand} | capacity ${activeWorkers}/${maxWorkers} | memory ${memPercent}% (${usedHeapMb}/${totalHeapMb}mb)`
|
|
187
|
+
);
|
|
181
188
|
app.events.emit(INTERNAL_CLAIM_START);
|
|
182
189
|
const start = Date.now();
|
|
183
190
|
app.queueChannel.push(CLAIM, {
|
package/dist/start.js
CHANGED
|
@@ -269,6 +269,7 @@ var tryWithBackoff = (fn, opts = {}) => {
|
|
|
269
269
|
var try_with_backoff_default = tryWithBackoff;
|
|
270
270
|
|
|
271
271
|
// src/api/claim.ts
|
|
272
|
+
import v8 from "node:v8";
|
|
272
273
|
import * as Sentry from "@sentry/node";
|
|
273
274
|
import crypto2 from "node:crypto";
|
|
274
275
|
import * as jose from "jose";
|
|
@@ -326,7 +327,13 @@ var claim = (app, logger2 = mockLogger, options = {}) => {
|
|
|
326
327
|
}
|
|
327
328
|
const claimId = ++claimIdGen;
|
|
328
329
|
app.openClaims[claimId] = demand;
|
|
329
|
-
|
|
330
|
+
const { used_heap_size, heap_size_limit } = v8.getHeapStatistics();
|
|
331
|
+
const usedHeapMb = Math.round(used_heap_size / 1024 / 1024);
|
|
332
|
+
const totalHeapMb = Math.round(heap_size_limit / 1024 / 1024);
|
|
333
|
+
const memPercent = Math.round(usedHeapMb / totalHeapMb * 100);
|
|
334
|
+
logger2.debug(
|
|
335
|
+
`Claiming runs :: demand ${demand} | capacity ${activeWorkers}/${maxWorkers} | memory ${memPercent}% (${usedHeapMb}/${totalHeapMb}mb)`
|
|
336
|
+
);
|
|
330
337
|
app.events.emit(INTERNAL_CLAIM_START);
|
|
331
338
|
const start = Date.now();
|
|
332
339
|
app.queueChannel.push(CLAIM, {
|
|
@@ -6421,6 +6428,9 @@ function setArg(argValue, envValue, defaultValue) {
|
|
|
6421
6428
|
if (typeof defaultValue === "number" && envValue && !argValue) {
|
|
6422
6429
|
return parseInt(envValue);
|
|
6423
6430
|
}
|
|
6431
|
+
if (typeof defaultValue === "boolean" && envValue && argValue === void 0) {
|
|
6432
|
+
return envValue === "true" || envValue === "1";
|
|
6433
|
+
}
|
|
6424
6434
|
return argValue ?? envValue ?? defaultValue;
|
|
6425
6435
|
}
|
|
6426
6436
|
function parseArgs(argv) {
|
|
@@ -6439,6 +6449,8 @@ function parseArgs(argv) {
|
|
|
6439
6449
|
WORKER_MAX_RUN_MEMORY_MB,
|
|
6440
6450
|
WORKER_MESSAGE_TIMEOUT_SECONDS,
|
|
6441
6451
|
WORKER_PORT,
|
|
6452
|
+
WORKER_PROFILE,
|
|
6453
|
+
WORKER_PROFILE_POLL_INTERVAL_MS,
|
|
6442
6454
|
WORKER_REPO_DIR,
|
|
6443
6455
|
WORKER_SECRET,
|
|
6444
6456
|
WORKER_SENTRY_DSN,
|
|
@@ -6521,6 +6533,12 @@ function parseArgs(argv) {
|
|
|
6521
6533
|
}).option("engine-validation-retries", {
|
|
6522
6534
|
description: "The number of times to retry engine validation. Useful in hosted environments. Default 3. ENV: WORKER_VALIDATION_RETRIES",
|
|
6523
6535
|
type: "number"
|
|
6536
|
+
}).option("profile", {
|
|
6537
|
+
description: "Enable profiling for runs. Default false. Env: WORKER_PROFILE",
|
|
6538
|
+
type: "boolean"
|
|
6539
|
+
}).option("profile-poll-interval-ms", {
|
|
6540
|
+
description: "Interval for polling profile data, in milliseconds. Default 10. Env: WORKER_PROFILE_POLL_INTERVAL_MS",
|
|
6541
|
+
type: "number"
|
|
6524
6542
|
});
|
|
6525
6543
|
const args2 = parser2.parse();
|
|
6526
6544
|
return {
|
|
@@ -6583,6 +6601,12 @@ function parseArgs(argv) {
|
|
|
6583
6601
|
args2.engineValidationTimeoutMs,
|
|
6584
6602
|
WORKER_VALIDATION_TIMEOUT_MS,
|
|
6585
6603
|
5e3
|
|
6604
|
+
),
|
|
6605
|
+
profile: setArg(args2.profile, WORKER_PROFILE, false),
|
|
6606
|
+
profilePollIntervalMs: setArg(
|
|
6607
|
+
args2.profilePollIntervalMs,
|
|
6608
|
+
WORKER_PROFILE_POLL_INTERVAL_MS,
|
|
6609
|
+
10
|
|
6586
6610
|
)
|
|
6587
6611
|
};
|
|
6588
6612
|
}
|
|
@@ -6662,7 +6686,9 @@ if (args.mock) {
|
|
|
6662
6686
|
statePropsToRemove: args.statePropsToRemove,
|
|
6663
6687
|
runTimeoutMs: args.maxRunDurationSeconds * 1e3,
|
|
6664
6688
|
workerValidationTimeout: args.engineValidationTimeoutMs,
|
|
6665
|
-
workerValidationRetries: args.engineValidationRetries
|
|
6689
|
+
workerValidationRetries: args.engineValidationRetries,
|
|
6690
|
+
profile: args.profile,
|
|
6691
|
+
profilePollInterval: args.profilePollIntervalMs
|
|
6666
6692
|
};
|
|
6667
6693
|
logger.debug("Creating runtime engine...");
|
|
6668
6694
|
logger.debug("Engine options:", engineOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/ws-worker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"koa-logger": "^3.2.1",
|
|
24
24
|
"phoenix": "1.7.10",
|
|
25
25
|
"ws": "^8.18.3",
|
|
26
|
-
"@openfn/logger": "1.0.6",
|
|
27
|
-
"@openfn/runtime": "1.7.3",
|
|
28
26
|
"@openfn/lexicon": "^1.2.5",
|
|
29
|
-
"@openfn/
|
|
27
|
+
"@openfn/runtime": "1.7.4",
|
|
28
|
+
"@openfn/logger": "1.0.6",
|
|
29
|
+
"@openfn/engine-multi": "1.8.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/koa": "^2.15.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"tsup": "^6.7.0",
|
|
44
44
|
"typescript": "^4.9.5",
|
|
45
45
|
"yargs": "^17.7.2",
|
|
46
|
-
"@openfn/lightning-mock": "2.3.
|
|
46
|
+
"@openfn/lightning-mock": "2.3.3"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|