@openfn/ws-worker 1.1.6 → 1.1.7
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 +6 -0
- package/dist/index.js +26 -6
- package/dist/start.js +26 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var name, version, description, main, type, scripts, bin, author, license, depen
|
|
|
29
29
|
var init_package = __esm({
|
|
30
30
|
"package.json"() {
|
|
31
31
|
name = "@openfn/ws-worker";
|
|
32
|
-
version = "1.1.
|
|
32
|
+
version = "1.1.7";
|
|
33
33
|
description = "A Websocket Worker to connect Lightning to a Runtime Engine";
|
|
34
34
|
main = "dist/index.js";
|
|
35
35
|
type = "module";
|
|
@@ -233,9 +233,11 @@ var claim = (app, logger = mockLogger, options = {}) => {
|
|
|
233
233
|
const { maxWorkers = 5 } = options;
|
|
234
234
|
const activeWorkers = Object.keys(app.workflows).length;
|
|
235
235
|
if (activeWorkers >= maxWorkers) {
|
|
236
|
+
logger.debug("skipping claim attempt: server at capacity");
|
|
236
237
|
return reject(new Error("Server at capacity"));
|
|
237
238
|
}
|
|
238
239
|
if (!app.queueChannel) {
|
|
240
|
+
logger.debug("skipping claim attempt: websocket unavailable");
|
|
239
241
|
return reject(new Error("No websocket available"));
|
|
240
242
|
}
|
|
241
243
|
logger.debug("requesting run...");
|
|
@@ -656,14 +658,21 @@ ${reason.error_type}: ${reason.error_message || "unknown"}`;
|
|
|
656
658
|
|
|
657
659
|
// src/events/run-complete.ts
|
|
658
660
|
async function onWorkflowComplete(context, _event) {
|
|
659
|
-
const { state, channel, onFinish } = context;
|
|
661
|
+
const { state, channel, onFinish, logger } = context;
|
|
660
662
|
const result = state.dataclips[state.lastDataclipId];
|
|
661
663
|
const reason = calculateRunExitReason(state);
|
|
662
664
|
await log_final_reason_default(context, reason);
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
665
|
+
try {
|
|
666
|
+
await sendEvent(channel, RUN_COMPLETE, {
|
|
667
|
+
final_dataclip_id: state.lastDataclipId,
|
|
668
|
+
...reason
|
|
669
|
+
});
|
|
670
|
+
} catch (e) {
|
|
671
|
+
logger.error(
|
|
672
|
+
`${state.plan.id} failed to send ${RUN_COMPLETE} event. This run will be lost!`
|
|
673
|
+
);
|
|
674
|
+
logger.error(e);
|
|
675
|
+
}
|
|
667
676
|
onFinish({ reason, state: result });
|
|
668
677
|
}
|
|
669
678
|
|
|
@@ -831,6 +840,16 @@ var joinRunChannel = (socket, token, runId, logger) => {
|
|
|
831
840
|
}).receive("error", (err) => {
|
|
832
841
|
logger.error(`error connecting to ${channelName}`, err);
|
|
833
842
|
reject(err);
|
|
843
|
+
}).receive("timeout", (err) => {
|
|
844
|
+
logger.error(`Timeout for ${channelName}`, err);
|
|
845
|
+
reject(err);
|
|
846
|
+
});
|
|
847
|
+
channel.onClose(() => {
|
|
848
|
+
logger.debug(`Leaving ${channelName}`);
|
|
849
|
+
});
|
|
850
|
+
channel.onError((e) => {
|
|
851
|
+
logger.debug(`Error in ${channelName}`);
|
|
852
|
+
logger.debug(e);
|
|
834
853
|
});
|
|
835
854
|
});
|
|
836
855
|
};
|
|
@@ -997,6 +1016,7 @@ function createServer(engine, options = {}) {
|
|
|
997
1016
|
input
|
|
998
1017
|
} = await run_default(app.socket, token, id, logger);
|
|
999
1018
|
const onFinish = () => {
|
|
1019
|
+
logger.debug(`workflow ${id} complete: releasing worker`);
|
|
1000
1020
|
delete app.workflows[id];
|
|
1001
1021
|
runChannel.leave();
|
|
1002
1022
|
app.events.emit(INTERNAL_RUN_COMPLETE);
|
package/dist/start.js
CHANGED
|
@@ -37,7 +37,7 @@ var name, version, description, main, type, scripts, bin, author, license, depen
|
|
|
37
37
|
var init_package = __esm({
|
|
38
38
|
"package.json"() {
|
|
39
39
|
name = "@openfn/ws-worker";
|
|
40
|
-
version = "1.1.
|
|
40
|
+
version = "1.1.7";
|
|
41
41
|
description = "A Websocket Worker to connect Lightning to a Runtime Engine";
|
|
42
42
|
main = "dist/index.js";
|
|
43
43
|
type = "module";
|
|
@@ -5224,9 +5224,11 @@ var claim = (app, logger2 = mockLogger, options = {}) => {
|
|
|
5224
5224
|
const { maxWorkers = 5 } = options;
|
|
5225
5225
|
const activeWorkers = Object.keys(app.workflows).length;
|
|
5226
5226
|
if (activeWorkers >= maxWorkers) {
|
|
5227
|
+
logger2.debug("skipping claim attempt: server at capacity");
|
|
5227
5228
|
return reject(new Error("Server at capacity"));
|
|
5228
5229
|
}
|
|
5229
5230
|
if (!app.queueChannel) {
|
|
5231
|
+
logger2.debug("skipping claim attempt: websocket unavailable");
|
|
5230
5232
|
return reject(new Error("No websocket available"));
|
|
5231
5233
|
}
|
|
5232
5234
|
logger2.debug("requesting run...");
|
|
@@ -5647,14 +5649,21 @@ ${reason.error_type}: ${reason.error_message || "unknown"}`;
|
|
|
5647
5649
|
|
|
5648
5650
|
// src/events/run-complete.ts
|
|
5649
5651
|
async function onWorkflowComplete(context, _event) {
|
|
5650
|
-
const { state, channel, onFinish } = context;
|
|
5652
|
+
const { state, channel, onFinish, logger: logger2 } = context;
|
|
5651
5653
|
const result = state.dataclips[state.lastDataclipId];
|
|
5652
5654
|
const reason = calculateRunExitReason(state);
|
|
5653
5655
|
await log_final_reason_default(context, reason);
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5656
|
+
try {
|
|
5657
|
+
await sendEvent(channel, RUN_COMPLETE, {
|
|
5658
|
+
final_dataclip_id: state.lastDataclipId,
|
|
5659
|
+
...reason
|
|
5660
|
+
});
|
|
5661
|
+
} catch (e) {
|
|
5662
|
+
logger2.error(
|
|
5663
|
+
`${state.plan.id} failed to send ${RUN_COMPLETE} event. This run will be lost!`
|
|
5664
|
+
);
|
|
5665
|
+
logger2.error(e);
|
|
5666
|
+
}
|
|
5658
5667
|
onFinish({ reason, state: result });
|
|
5659
5668
|
}
|
|
5660
5669
|
|
|
@@ -5822,6 +5831,16 @@ var joinRunChannel = (socket, token, runId, logger2) => {
|
|
|
5822
5831
|
}).receive("error", (err) => {
|
|
5823
5832
|
logger2.error(`error connecting to ${channelName}`, err);
|
|
5824
5833
|
reject(err);
|
|
5834
|
+
}).receive("timeout", (err) => {
|
|
5835
|
+
logger2.error(`Timeout for ${channelName}`, err);
|
|
5836
|
+
reject(err);
|
|
5837
|
+
});
|
|
5838
|
+
channel.onClose(() => {
|
|
5839
|
+
logger2.debug(`Leaving ${channelName}`);
|
|
5840
|
+
});
|
|
5841
|
+
channel.onError((e) => {
|
|
5842
|
+
logger2.debug(`Error in ${channelName}`);
|
|
5843
|
+
logger2.debug(e);
|
|
5825
5844
|
});
|
|
5826
5845
|
});
|
|
5827
5846
|
};
|
|
@@ -5988,6 +6007,7 @@ function createServer(engine, options = {}) {
|
|
|
5988
6007
|
input
|
|
5989
6008
|
} = await run_default(app.socket, token, id, logger2);
|
|
5990
6009
|
const onFinish = () => {
|
|
6010
|
+
logger2.debug(`workflow ${id} complete: releasing worker`);
|
|
5991
6011
|
delete app.workflows[id];
|
|
5992
6012
|
runChannel.leave();
|
|
5993
6013
|
app.events.emit(INTERNAL_RUN_COMPLETE);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/ws-worker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"phoenix": "1.7.10",
|
|
24
24
|
"ws": "^8.14.1",
|
|
25
25
|
"@openfn/engine-multi": "1.1.6",
|
|
26
|
-
"@openfn/logger": "1.0.1",
|
|
27
26
|
"@openfn/lexicon": "^1.0.1",
|
|
27
|
+
"@openfn/logger": "1.0.1",
|
|
28
28
|
"@openfn/runtime": "1.1.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|