@openfn/ws-worker 1.16.1 → 1.18.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 +23 -0
- package/dist/index.js +10 -9
- package/dist/start.js +44 -14
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# ws-worker
|
|
2
2
|
|
|
3
|
+
## 1.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cf8d3c2: Add retry with backoff to worker validation
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [cf8d3c2]
|
|
12
|
+
- @openfn/engine-multi@1.7.0
|
|
13
|
+
|
|
14
|
+
## 1.17.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 09dd4b2: - Add `final_state` object to `workflow:complete` event
|
|
19
|
+
- Remove unused `final_dataclip_id` from `workflow:complete` payload
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [09dd4b2]
|
|
24
|
+
- @openfn/lexicon@1.2.4
|
|
25
|
+
|
|
3
26
|
## 1.16.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -348,10 +348,6 @@ var convert_lightning_plan_default = (run, options = {}) => {
|
|
|
348
348
|
engineOpts.jobLogLevel = run.options.job_log_level;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
const plan = {
|
|
352
|
-
id: run.id,
|
|
353
|
-
options: runtimeOpts
|
|
354
|
-
};
|
|
355
351
|
let initialState;
|
|
356
352
|
if (run.dataclip_id) {
|
|
357
353
|
initialState = run.dataclip_id;
|
|
@@ -415,8 +411,14 @@ var convert_lightning_plan_default = (run, options = {}) => {
|
|
|
415
411
|
nodes[id] = job;
|
|
416
412
|
});
|
|
417
413
|
}
|
|
418
|
-
plan
|
|
419
|
-
|
|
414
|
+
const plan = {
|
|
415
|
+
id: run.id,
|
|
416
|
+
options: runtimeOpts,
|
|
417
|
+
workflow: {
|
|
418
|
+
// id: run.workflowId, // TODO: lightning does not send this
|
|
419
|
+
// name: run.name, // TODO: lightning does not send this
|
|
420
|
+
steps: Object.values(nodes)
|
|
421
|
+
}
|
|
420
422
|
};
|
|
421
423
|
if (run.globals && typeof run.globals === "string")
|
|
422
424
|
plan.workflow.globals = run.globals;
|
|
@@ -806,12 +808,12 @@ var log_final_reason_default = async (context, reason) => {
|
|
|
806
808
|
// src/events/run-complete.ts
|
|
807
809
|
async function onWorkflowComplete(context, event) {
|
|
808
810
|
const { state, onFinish, logger } = context;
|
|
809
|
-
const result =
|
|
811
|
+
const result = event.state;
|
|
810
812
|
const reason = calculateRunExitReason(state);
|
|
811
813
|
await log_final_reason_default(context, reason);
|
|
812
814
|
try {
|
|
813
815
|
await sendEvent(context, RUN_COMPLETE, {
|
|
814
|
-
|
|
816
|
+
final_state: result,
|
|
815
817
|
timestamp: timeInMicroseconds(event.time),
|
|
816
818
|
...reason
|
|
817
819
|
});
|
|
@@ -834,7 +836,6 @@ async function onRunError(context, event) {
|
|
|
834
836
|
}
|
|
835
837
|
await log_final_reason_default(context, reason);
|
|
836
838
|
await sendEvent(context, RUN_COMPLETE, {
|
|
837
|
-
final_dataclip_id: state.lastDataclipId,
|
|
838
839
|
...reason
|
|
839
840
|
});
|
|
840
841
|
onFinish({ reason });
|
package/dist/start.js
CHANGED
|
@@ -105,10 +105,19 @@ async function createMock() {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
setTimeout(async () => {
|
|
108
|
+
const startTime = Date.now();
|
|
108
109
|
dispatch("workflow-start", { workflowId: id, threadId });
|
|
109
110
|
try {
|
|
110
|
-
await run(xplan, input, opts);
|
|
111
|
-
|
|
111
|
+
const result = await run(xplan, input, opts);
|
|
112
|
+
const duration = Date.now() - startTime;
|
|
113
|
+
dispatch("workflow-complete", {
|
|
114
|
+
workflowId: id,
|
|
115
|
+
threadId,
|
|
116
|
+
state: result,
|
|
117
|
+
duration,
|
|
118
|
+
time: BigInt(Date.now()) * BigInt(1e6)
|
|
119
|
+
// Convert to nanoseconds
|
|
120
|
+
});
|
|
112
121
|
} catch (e) {
|
|
113
122
|
dispatch("workflow-error", {
|
|
114
123
|
threadId,
|
|
@@ -488,10 +497,6 @@ var convert_lightning_plan_default = (run2, options = {}) => {
|
|
|
488
497
|
engineOpts.jobLogLevel = run2.options.job_log_level;
|
|
489
498
|
}
|
|
490
499
|
}
|
|
491
|
-
const plan = {
|
|
492
|
-
id: run2.id,
|
|
493
|
-
options: runtimeOpts
|
|
494
|
-
};
|
|
495
500
|
let initialState;
|
|
496
501
|
if (run2.dataclip_id) {
|
|
497
502
|
initialState = run2.dataclip_id;
|
|
@@ -555,8 +560,14 @@ var convert_lightning_plan_default = (run2, options = {}) => {
|
|
|
555
560
|
nodes[id] = job;
|
|
556
561
|
});
|
|
557
562
|
}
|
|
558
|
-
plan
|
|
559
|
-
|
|
563
|
+
const plan = {
|
|
564
|
+
id: run2.id,
|
|
565
|
+
options: runtimeOpts,
|
|
566
|
+
workflow: {
|
|
567
|
+
// id: run.workflowId, // TODO: lightning does not send this
|
|
568
|
+
// name: run.name, // TODO: lightning does not send this
|
|
569
|
+
steps: Object.values(nodes)
|
|
570
|
+
}
|
|
560
571
|
};
|
|
561
572
|
if (run2.globals && typeof run2.globals === "string")
|
|
562
573
|
plan.workflow.globals = run2.globals;
|
|
@@ -946,12 +957,12 @@ var log_final_reason_default = async (context, reason) => {
|
|
|
946
957
|
// src/events/run-complete.ts
|
|
947
958
|
async function onWorkflowComplete(context, event) {
|
|
948
959
|
const { state, onFinish, logger: logger2 } = context;
|
|
949
|
-
const result =
|
|
960
|
+
const result = event.state;
|
|
950
961
|
const reason = calculateRunExitReason(state);
|
|
951
962
|
await log_final_reason_default(context, reason);
|
|
952
963
|
try {
|
|
953
964
|
await sendEvent(context, RUN_COMPLETE, {
|
|
954
|
-
|
|
965
|
+
final_state: result,
|
|
955
966
|
timestamp: timeInMicroseconds(event.time),
|
|
956
967
|
...reason
|
|
957
968
|
});
|
|
@@ -974,7 +985,6 @@ async function onRunError(context, event) {
|
|
|
974
985
|
}
|
|
975
986
|
await log_final_reason_default(context, reason);
|
|
976
987
|
await sendEvent(context, RUN_COMPLETE, {
|
|
977
|
-
final_dataclip_id: state.lastDataclipId,
|
|
978
988
|
...reason
|
|
979
989
|
});
|
|
980
990
|
onFinish({ reason });
|
|
@@ -6431,7 +6441,9 @@ function parseArgs(argv) {
|
|
|
6431
6441
|
WORKER_SENTRY_DSN,
|
|
6432
6442
|
WORKER_SENTRY_ENV,
|
|
6433
6443
|
WORKER_SOCKET_TIMEOUT_SECONDS,
|
|
6434
|
-
WORKER_STATE_PROPS_TO_REMOVE
|
|
6444
|
+
WORKER_STATE_PROPS_TO_REMOVE,
|
|
6445
|
+
WORKER_VALIDATION_RETRIES,
|
|
6446
|
+
WORKER_VALIDATION_TIMEOUT_MS
|
|
6435
6447
|
} = process.env;
|
|
6436
6448
|
const parser2 = yargs_default(hideBin(argv)).command("server", "Start a ws-worker server").option("debug", {
|
|
6437
6449
|
hidden: true,
|
|
@@ -6500,6 +6512,12 @@ function parseArgs(argv) {
|
|
|
6500
6512
|
}).option("collections-version", {
|
|
6501
6513
|
description: "The version of the collections adaptor to use for all runs on this worker instance.Env: WORKER_COLLECTIONS_VERSION",
|
|
6502
6514
|
type: "string"
|
|
6515
|
+
}).option("engine-validation-timeout-ms", {
|
|
6516
|
+
description: "The timeout used to run the validation task within the engine, in milliseconds. Env: WORKER_VALIDATION_TIMEOUT_MS",
|
|
6517
|
+
type: "number"
|
|
6518
|
+
}).option("engine-validation-retries", {
|
|
6519
|
+
description: "The number of times to retry engine validation. Useful in hosted environments. Default 3. ENV: WORKER_VALIDATION_RETRIES",
|
|
6520
|
+
type: "number"
|
|
6503
6521
|
});
|
|
6504
6522
|
const args2 = parser2.parse();
|
|
6505
6523
|
return {
|
|
@@ -6552,7 +6570,17 @@ function parseArgs(argv) {
|
|
|
6552
6570
|
args2.collectionsVersion,
|
|
6553
6571
|
WORKER_COLLECTIONS_VERSION
|
|
6554
6572
|
),
|
|
6555
|
-
collectionsUrl: setArg(args2.collectionsUrl, WORKER_COLLECTIONS_URL)
|
|
6573
|
+
collectionsUrl: setArg(args2.collectionsUrl, WORKER_COLLECTIONS_URL),
|
|
6574
|
+
engineValidationRetries: setArg(
|
|
6575
|
+
args2.engineValidationRetries,
|
|
6576
|
+
WORKER_VALIDATION_RETRIES,
|
|
6577
|
+
3
|
|
6578
|
+
),
|
|
6579
|
+
engineValidationTimeoutMs: setArg(
|
|
6580
|
+
args2.engineValidationTimeoutMs,
|
|
6581
|
+
WORKER_VALIDATION_TIMEOUT_MS,
|
|
6582
|
+
5e3
|
|
6583
|
+
)
|
|
6556
6584
|
};
|
|
6557
6585
|
}
|
|
6558
6586
|
|
|
@@ -6629,7 +6657,9 @@ if (args.mock) {
|
|
|
6629
6657
|
memoryLimitMb: args.runMemory,
|
|
6630
6658
|
maxWorkers: args.capacity,
|
|
6631
6659
|
statePropsToRemove: args.statePropsToRemove,
|
|
6632
|
-
runTimeoutMs: args.maxRunDurationSeconds * 1e3
|
|
6660
|
+
runTimeoutMs: args.maxRunDurationSeconds * 1e3,
|
|
6661
|
+
workerValidationTimeout: args.engineValidationTimeoutMs,
|
|
6662
|
+
workerValidationRetries: args.engineValidationRetries
|
|
6633
6663
|
};
|
|
6634
6664
|
logger.debug("Creating runtime engine...");
|
|
6635
6665
|
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.18.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/engine-multi": "1.
|
|
27
|
-
"@openfn/
|
|
28
|
-
"@openfn/
|
|
29
|
-
"@openfn/
|
|
26
|
+
"@openfn/engine-multi": "1.7.0",
|
|
27
|
+
"@openfn/runtime": "1.7.3",
|
|
28
|
+
"@openfn/lexicon": "^1.2.5",
|
|
29
|
+
"@openfn/logger": "1.0.6"
|
|
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.
|
|
46
|
+
"@openfn/lightning-mock": "2.3.1"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|