@openfn/ws-worker 0.2.11 → 0.2.12

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # ws-worker
2
2
 
3
+ ## 0.2.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 6c3e9e42: Ensure capacity is also set on the engine
8
+ - Updated dependencies [05ccc10b]
9
+ - Updated dependencies [7235bf5e]
10
+ - @openfn/engine-multi@0.2.3
11
+
3
12
  ## 0.2.11
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -409,7 +409,7 @@ function onJobStart({ channel, state }, event) {
409
409
  });
410
410
  }
411
411
  function onJobError(context, event) {
412
- const { state, error, jobId } = event;
412
+ const { state = {}, error, jobId } = event;
413
413
  if (state.errors?.[jobId]?.message === error.message) {
414
414
  onJobComplete(context, event);
415
415
  } else {
@@ -462,9 +462,13 @@ async function onWorkflowComplete({ state, channel, onFinish }, _event) {
462
462
  });
463
463
  onFinish({ reason, state: result });
464
464
  }
465
- async function onWorkflowError({ state, channel, logger, onFinish }, event) {
465
+ async function onWorkflowError(context, event) {
466
+ const { state, channel, logger, onFinish } = context;
466
467
  try {
467
468
  const reason = calculateJobExitReason("", { data: {} }, event);
469
+ if (state.activeJob) {
470
+ await onJobError(context, { error: event });
471
+ }
468
472
  await sendEvent(channel, ATTEMPT_COMPLETE, {
469
473
  final_dataclip_id: state.lastDataclipId,
470
474
  ...reason
@@ -473,6 +477,7 @@ async function onWorkflowError({ state, channel, logger, onFinish }, event) {
473
477
  } catch (e) {
474
478
  logger.error("ERROR in workflow-error handler:", e.message);
475
479
  logger.error(e);
480
+ onFinish({});
476
481
  }
477
482
  }
478
483
  function onJobLog({ channel, state }, event) {
package/dist/start.js CHANGED
@@ -4954,6 +4954,7 @@ async function createMock() {
4954
4954
  dispatch("workflow-start", { workflowId: id, threadId });
4955
4955
  try {
4956
4956
  await run(xplan, void 0, opts);
4957
+ dispatch("workflow-complete", { workflowId: id, threadId });
4957
4958
  } catch (e) {
4958
4959
  dispatch("workflow-error", {
4959
4960
  threadId,
@@ -4961,9 +4962,9 @@ async function createMock() {
4961
4962
  type: e.name,
4962
4963
  message: e.message
4963
4964
  });
4965
+ } finally {
4966
+ delete activeWorkflows[id];
4964
4967
  }
4965
- delete activeWorkflows[id];
4966
- dispatch("workflow-complete", { workflowId: id, threadId });
4967
4968
  }, 1);
4968
4969
  };
4969
4970
  const getStatus = () => {
@@ -5394,7 +5395,7 @@ function onJobStart({ channel, state }, event) {
5394
5395
  });
5395
5396
  }
5396
5397
  function onJobError(context, event) {
5397
- const { state, error, jobId } = event;
5398
+ const { state = {}, error, jobId } = event;
5398
5399
  if (state.errors?.[jobId]?.message === error.message) {
5399
5400
  onJobComplete(context, event);
5400
5401
  } else {
@@ -5447,9 +5448,13 @@ async function onWorkflowComplete({ state, channel, onFinish }, _event) {
5447
5448
  });
5448
5449
  onFinish({ reason, state: result });
5449
5450
  }
5450
- async function onWorkflowError({ state, channel, logger: logger2, onFinish }, event) {
5451
+ async function onWorkflowError(context, event) {
5452
+ const { state, channel, logger: logger2, onFinish } = context;
5451
5453
  try {
5452
5454
  const reason = calculateJobExitReason("", { data: {} }, event);
5455
+ if (state.activeJob) {
5456
+ await onJobError(context, { error: event });
5457
+ }
5453
5458
  await sendEvent(channel, ATTEMPT_COMPLETE, {
5454
5459
  final_dataclip_id: state.lastDataclipId,
5455
5460
  ...reason
@@ -5458,6 +5463,7 @@ async function onWorkflowError({ state, channel, logger: logger2, onFinish }, ev
5458
5463
  } catch (e) {
5459
5464
  logger2.error("ERROR in workflow-error handler:", e.message);
5460
5465
  logger2.error(e);
5466
+ onFinish({});
5461
5467
  }
5462
5468
  }
5463
5469
  function onJobLog({ channel, state }, event) {
@@ -5790,12 +5796,14 @@ if (args.mock) {
5790
5796
  engineReady(engine);
5791
5797
  });
5792
5798
  } else {
5793
- createRTE({ repoDir: args.repoDir, memoryLimitMb: args.runMemory }).then(
5794
- (engine) => {
5795
- logger.debug("engine created");
5796
- engineReady(engine);
5797
- }
5798
- );
5799
+ createRTE({
5800
+ repoDir: args.repoDir,
5801
+ memoryLimitMb: args.runMemory,
5802
+ maxWorkers: args.capacity
5803
+ }).then((engine) => {
5804
+ logger.debug("engine created");
5805
+ engineReady(engine);
5806
+ });
5799
5807
  }
5800
5808
  /**
5801
5809
  * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/ws-worker",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "A Websocket Worker to connect Lightning to a Runtime Engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "koa-logger": "^3.2.1",
22
22
  "phoenix": "^1.7.7",
23
23
  "ws": "^8.14.1",
24
- "@openfn/engine-multi": "0.2.2",
24
+ "@openfn/engine-multi": "0.2.3",
25
25
  "@openfn/logger": "0.0.19",
26
26
  "@openfn/runtime": "0.2.1"
27
27
  },
@@ -40,7 +40,7 @@
40
40
  "tsup": "^6.2.3",
41
41
  "typescript": "^4.6.4",
42
42
  "yargs": "^17.6.2",
43
- "@openfn/lightning-mock": "1.1.4"
43
+ "@openfn/lightning-mock": "1.1.5"
44
44
  },
45
45
  "files": [
46
46
  "dist",