@falcondev-oss/workflow 0.8.5 → 0.8.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/dist/index.d.mts CHANGED
@@ -12,6 +12,7 @@ type WorkflowLogger = {
12
12
  info?: (...data: any[]) => void;
13
13
  success?: (...data: any[]) => void;
14
14
  error?: (...data: any[]) => void;
15
+ debug?: (...data: any[]) => void;
15
16
  };
16
17
  declare const Settings: {
17
18
  defaultConnection: (() => Promise<IORedis> | IORedis) | undefined;
@@ -41,6 +42,7 @@ declare class WorkflowStep {
41
42
  private queue;
42
43
  private workflowJobId;
43
44
  private stepNamePrefix;
45
+ private updateStepDataMutex;
44
46
  constructor(opts: {
45
47
  queue: WorkflowQueueInternal<unknown>;
46
48
  workflowJobId: string;
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ import { ROOT_CONTEXT, SpanKind, SpanStatusCode, context, propagation, trace } f
6
6
  import { asyncExitHook } from "exit-hook";
7
7
  import { setInterval as setInterval$1, setTimeout as setTimeout$1 } from "node:timers/promises";
8
8
  import { deserialize, serialize } from "superjson";
9
+ import Mutex from "p-mutex";
9
10
  import pRetry from "p-retry";
10
11
 
11
12
  //#region rolldown:runtime
@@ -9610,6 +9611,7 @@ var WorkflowStep = class WorkflowStep {
9610
9611
  queue;
9611
9612
  workflowJobId;
9612
9613
  stepNamePrefix;
9614
+ updateStepDataMutex = new Mutex();
9613
9615
  constructor(opts) {
9614
9616
  this.queue = opts.queue;
9615
9617
  this.workflowJobId = opts.workflowJobId;
@@ -9698,10 +9700,12 @@ var WorkflowStep = class WorkflowStep {
9698
9700
  return stepData;
9699
9701
  }
9700
9702
  async updateStepData(stepName, data) {
9701
- const job = await this.getWorkflowJob();
9702
- const jobData = deserialize$1(job.data);
9703
- jobData.stepData[stepName] = data;
9704
- await job.updateData(serialize$1(jobData));
9703
+ await this.updateStepDataMutex.withLock(async () => {
9704
+ const job = await this.getWorkflowJob();
9705
+ const jobData = deserialize$1(job.data);
9706
+ jobData.stepData[stepName] = data;
9707
+ await job.updateData(serialize$1(jobData));
9708
+ });
9705
9709
  }
9706
9710
  async getWorkflowJob() {
9707
9711
  const job = await this.queue.getJob(this.workflowJobId);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@falcondev-oss/workflow",
3
3
  "type": "module",
4
- "version": "0.8.5",
4
+ "version": "0.8.7",
5
5
  "description": "Simple type-safe queue worker with durable execution using Redis.",
6
6
  "license": "MIT",
7
7
  "repository": "github:falcondev-oss/workflow",
@@ -41,6 +41,7 @@
41
41
  "exit-hook": "^5.0.1",
42
42
  "groupmq": "^1.1.0",
43
43
  "ioredis": "^5.9.2",
44
+ "p-mutex": "^1.0.0",
44
45
  "p-retry": "^7.1.1",
45
46
  "superjson": "^2.2.6",
46
47
  "type-fest": "^5.4.2"