codehooks-js 1.3.9 → 1.3.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codehooks-js",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "type": "module",
5
5
  "description": "Codehooks.io official library - provides express.JS like syntax",
6
6
  "main": "index.js",
@@ -254,7 +254,7 @@ class Workflow extends EventEmitter {
254
254
  const func = this.getDefinition(stepsName, nextStep);
255
255
 
256
256
  // Wrap the callback in a Promise to ensure proper async handling
257
- await new Promise(async (resolve, reject) => {
257
+ return await new Promise(async (resolve, reject) => {
258
258
  // check if the step count is greater than the max step count
259
259
  if (newState.stepCount[nextStep].visits > this.getMaxStepCount()) {
260
260
  reject(new Error(`Step ${nextStep} has been executed ${newState.stepCount[nextStep].visits} times, which is greater than the maximum step count of ${this.getMaxStepCount()}`));
@@ -371,6 +371,7 @@ class Workflow extends EventEmitter {
371
371
  reject(error);
372
372
  }
373
373
  });
374
+ resolve();
374
375
  } catch (error) {
375
376
  console.error('Error executing step function:', error);
376
377
  reject(error);
@@ -432,6 +433,8 @@ class Workflow extends EventEmitter {
432
433
  const { stepsName, goto, state, instanceId, options } = req.body.payload;
433
434
  console.debug('dequeue step', stepName, instanceId);
434
435
  const qid = await this.handleNextStep(stepsName, goto, state, instanceId, options);
436
+ //console.debug('Worker qid', qid);
437
+ //res.end();
435
438
  } catch (error) {
436
439
  const { stepsName, goto, state, instanceId, options } = req.body.payload;
437
440
  const connection = await Datastore.open();
@@ -441,6 +444,7 @@ class Workflow extends EventEmitter {
441
444
  console.error('Error in function: ' + stepName, error);
442
445
  this.emit('error', error);
443
446
  } finally {
447
+ //console.debug('Worker res.end', stepName);
444
448
  res.end();
445
449
  }
446
450
  });
@@ -549,7 +553,7 @@ class Workflow extends EventEmitter {
549
553
  { _id: instanceId },
550
554
  { $set: { ...state, updatedAt: new Date().toISOString() } });
551
555
  if (options.continue) {
552
- await this.continue(stepsName, instanceId);
556
+ await this.continue(stepsName, instanceId, false);
553
557
  }
554
558
  resolve({ ...doc });
555
559
  });