@openfn/ws-worker 1.22.0 → 1.22.1

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,15 @@
1
1
  # ws-worker
2
2
 
3
+ ## 1.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6fd3942: Fix an issue where unhandled errors could trigger a worker crash after a compilation error.
8
+ - 32b43cb: When reporting compilation errors, prefer the step name to the id
9
+ - Updated dependencies [6fd3942]
10
+ - Updated dependencies [32b43cb]
11
+ - @openfn/engine-multi@1.10.5
12
+
3
13
  ## 1.22.0
4
14
 
5
15
  ### Minor Changes
package/dist/index.js CHANGED
@@ -40,13 +40,12 @@ var destroy = async (app, logger) => {
40
40
  resolve();
41
41
  });
42
42
  }),
43
- new Promise(async (resolve) => {
43
+ (async () => {
44
44
  await waitForRunsAndClaims(app, logger);
45
45
  app.queueChannel?.leave();
46
46
  await app.engine.destroy();
47
47
  app.socket?.disconnect();
48
- resolve();
49
- })
48
+ })()
50
49
  ]);
51
50
  logger.success("Server closed");
52
51
  };
@@ -508,36 +507,35 @@ var tryWithBackoff = (fn, opts = {}) => {
508
507
  if (!opts.isCancelled) {
509
508
  opts.isCancelled = () => cancelled;
510
509
  }
511
- const promise = new Promise(async (resolve, reject) => {
510
+ const run = async () => {
512
511
  try {
513
512
  await fn();
514
- resolve();
515
513
  } catch (e) {
516
514
  if (e?.abort) {
517
515
  cancelled = true;
518
- return reject();
516
+ throw e;
519
517
  }
520
518
  if (opts.isCancelled()) {
521
- return resolve();
519
+ return;
522
520
  }
523
521
  if (!isNaN(maxRuns) && runs >= maxRuns) {
524
- return reject(new Error("max runs exceeded"));
522
+ throw new Error("max runs exceeded");
525
523
  }
526
- setTimeout(() => {
527
- if (opts.isCancelled()) {
528
- return resolve();
529
- }
530
- const nextOpts = {
531
- maxRuns,
532
- runs: runs + 1,
533
- min: Math.min(max, min * BACKOFF_MULTIPLIER),
534
- max,
535
- isCancelled: opts.isCancelled
536
- };
537
- tryWithBackoff(fn, nextOpts).then(resolve).catch(reject);
538
- }, min);
524
+ await new Promise((resolve) => setTimeout(resolve, min));
525
+ if (opts.isCancelled()) {
526
+ return;
527
+ }
528
+ const nextOpts = {
529
+ maxRuns,
530
+ runs: runs + 1,
531
+ min: Math.min(max, min * BACKOFF_MULTIPLIER),
532
+ max,
533
+ isCancelled: opts.isCancelled
534
+ };
535
+ return tryWithBackoff(fn, nextOpts);
539
536
  }
540
- });
537
+ };
538
+ const promise = run();
541
539
  promise.cancel = () => {
542
540
  cancelled = true;
543
541
  };
@@ -585,16 +583,13 @@ async function onRunLog(context, events) {
585
583
  };
586
584
  return sendEvent(context, RUN_LOG_BATCH, payload);
587
585
  } else {
588
- return new Promise(async (resolve) => {
589
- for (const log of logs) {
590
- const payload = {
591
- run_id: `${state.plan.id}`,
592
- ...log
593
- };
594
- await sendEvent(context, RUN_LOG, payload);
595
- }
596
- resolve();
597
- });
586
+ for (const log of logs) {
587
+ const payload = {
588
+ run_id: `${state.plan.id}`,
589
+ ...log
590
+ };
591
+ await sendEvent(context, RUN_LOG, payload);
592
+ }
598
593
  }
599
594
  }
600
595
 
package/dist/start.js CHANGED
@@ -189,13 +189,12 @@ var destroy = async (app, logger2) => {
189
189
  resolve5();
190
190
  });
191
191
  }),
192
- new Promise(async (resolve5) => {
192
+ (async () => {
193
193
  await waitForRunsAndClaims(app, logger2);
194
194
  app.queueChannel?.leave();
195
195
  await app.engine.destroy();
196
196
  app.socket?.disconnect();
197
- resolve5();
198
- })
197
+ })()
199
198
  ]);
200
199
  logger2.success("Server closed");
201
200
  };
@@ -657,36 +656,35 @@ var tryWithBackoff = (fn, opts = {}) => {
657
656
  if (!opts.isCancelled) {
658
657
  opts.isCancelled = () => cancelled;
659
658
  }
660
- const promise = new Promise(async (resolve5, reject) => {
659
+ const run2 = async () => {
661
660
  try {
662
661
  await fn();
663
- resolve5();
664
662
  } catch (e) {
665
663
  if (e?.abort) {
666
664
  cancelled = true;
667
- return reject();
665
+ throw e;
668
666
  }
669
667
  if (opts.isCancelled()) {
670
- return resolve5();
668
+ return;
671
669
  }
672
670
  if (!isNaN(maxRuns) && runs >= maxRuns) {
673
- return reject(new Error("max runs exceeded"));
671
+ throw new Error("max runs exceeded");
674
672
  }
675
- setTimeout(() => {
676
- if (opts.isCancelled()) {
677
- return resolve5();
678
- }
679
- const nextOpts = {
680
- maxRuns,
681
- runs: runs + 1,
682
- min: Math.min(max, min * BACKOFF_MULTIPLIER),
683
- max,
684
- isCancelled: opts.isCancelled
685
- };
686
- tryWithBackoff(fn, nextOpts).then(resolve5).catch(reject);
687
- }, min);
673
+ await new Promise((resolve5) => setTimeout(resolve5, min));
674
+ if (opts.isCancelled()) {
675
+ return;
676
+ }
677
+ const nextOpts = {
678
+ maxRuns,
679
+ runs: runs + 1,
680
+ min: Math.min(max, min * BACKOFF_MULTIPLIER),
681
+ max,
682
+ isCancelled: opts.isCancelled
683
+ };
684
+ return tryWithBackoff(fn, nextOpts);
688
685
  }
689
- });
686
+ };
687
+ const promise = run2();
690
688
  promise.cancel = () => {
691
689
  cancelled = true;
692
690
  };
@@ -734,16 +732,13 @@ async function onRunLog(context, events) {
734
732
  };
735
733
  return sendEvent(context, RUN_LOG_BATCH, payload);
736
734
  } else {
737
- return new Promise(async (resolve5) => {
738
- for (const log of logs) {
739
- const payload = {
740
- run_id: `${state.plan.id}`,
741
- ...log
742
- };
743
- await sendEvent(context, RUN_LOG, payload);
744
- }
745
- resolve5();
746
- });
735
+ for (const log of logs) {
736
+ const payload = {
737
+ run_id: `${state.plan.id}`,
738
+ ...log
739
+ };
740
+ await sendEvent(context, RUN_LOG, payload);
741
+ }
747
742
  }
748
743
  }
749
744
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/ws-worker",
3
- "version": "1.22.0",
3
+ "version": "1.22.1",
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.10.4",
27
- "@openfn/logger": "1.1.1",
26
+ "@openfn/engine-multi": "1.10.5",
28
27
  "@openfn/lexicon": "^1.4.1",
29
- "@openfn/runtime": "1.8.4"
28
+ "@openfn/runtime": "1.8.4",
29
+ "@openfn/logger": "1.1.1"
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.4.5"
46
+ "@openfn/lightning-mock": "2.4.7"
47
47
  },
48
48
  "files": [
49
49
  "dist",