@workflow/world-testing 4.1.0-beta.73 → 4.1.0-beta.74

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.
@@ -52682,6 +52682,12 @@ function createEventsStorage(basedir, tag) {
52682
52682
  };
52683
52683
  await writeJSON(taggedPath(basedir, "hooks", data.correlationId, tag), hook);
52684
52684
  } else if (data.eventType === "hook_disposed") {
52685
+ const hookLockName = tag ? `${data.correlationId}.disposed.${tag}` : `${data.correlationId}.disposed`;
52686
+ const lockPath = import_node_path5.default.join(basedir, ".locks", "hooks", hookLockName);
52687
+ const claimed = await writeExclusive(lockPath, "");
52688
+ if (!claimed) {
52689
+ throw new EntityConflictError(`Hook "${data.correlationId}" already disposed`);
52690
+ }
52685
52691
  const hookPath = taggedPath(basedir, "hooks", data.correlationId, tag);
52686
52692
  const existingHook = await readJSONWithFallback(basedir, "hooks", data.correlationId, HookSchema, tag);
52687
52693
  if (existingHook) {
@@ -59221,7 +59227,13 @@ async function handleSuspension({ suspension, world, run, span, requestId }) {
59221
59227
  try {
59222
59228
  await world.events.create(runId, hookDisposedEvent, { requestId });
59223
59229
  } catch (err) {
59224
- if (EntityConflictError.is(err) || RunExpiredError.is(err)) {
59230
+ if (EntityConflictError.is(err)) {
59231
+ runtimeLogger.info("Hook already disposed, skipping duplicate disposal", {
59232
+ workflowRunId: runId,
59233
+ correlationId: queueItem.correlationId,
59234
+ message: err.message
59235
+ });
59236
+ } else if (RunExpiredError.is(err)) {
59225
59237
  runtimeLogger.info("Workflow run already completed, skipping hook disposal", {
59226
59238
  workflowRunId: runId,
59227
59239
  correlationId: queueItem.correlationId,
@@ -60312,6 +60324,9 @@ function createContext(options) {
60312
60324
  g.URL = globalThis.URL;
60313
60325
  g.URLSearchParams = globalThis.URLSearchParams;
60314
60326
  g.structuredClone = globalThis.structuredClone;
60327
+ g.atob = globalThis.atob;
60328
+ g.btoa = globalThis.btoa;
60329
+ g.Buffer = Buffer;
60315
60330
  g.Symbol.dispose ??= /* @__PURE__ */ Symbol.for("Symbol.dispose");
60316
60331
  g.Symbol.asyncDispose ??= /* @__PURE__ */ Symbol.for("Symbol.asyncDispose");
60317
60332
  g.exports = {};
@@ -1,22 +1,9 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
- "workflows/noop.ts": {
5
- "noop": {
6
- "stepId": "step//./workflows/noop//noop"
7
- }
8
- },
9
- "workflows/retriable-and-fatal.ts": {
10
- "stepThatFails": {
11
- "stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
12
- },
13
- "stepThatThrowsRetryableError": {
14
- "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
15
- }
16
- },
17
- "workflows/hooks.ts": {
18
- "writeEvent": {
19
- "stepId": "step//./workflows/hooks//writeEvent"
4
+ "workflows/null-byte.ts": {
5
+ "nullByteStep": {
6
+ "stepId": "step//./workflows/null-byte//nullByteStep"
20
7
  }
21
8
  },
22
9
  "workflows/addition.ts": {
@@ -24,11 +11,6 @@
24
11
  "stepId": "step//./workflows/addition//add"
25
12
  }
26
13
  },
27
- "workflows/null-byte.ts": {
28
- "nullByteStep": {
29
- "stepId": "step//./workflows/null-byte//nullByteStep"
30
- }
31
- },
32
14
  "workflow/dist/internal/builtins.js": {
33
15
  "__builtin_response_array_buffer": {
34
16
  "stepId": "__builtin_response_array_buffer"
@@ -39,19 +21,37 @@
39
21
  "__builtin_response_text": {
40
22
  "stepId": "__builtin_response_text"
41
23
  }
24
+ },
25
+ "workflows/noop.ts": {
26
+ "noop": {
27
+ "stepId": "step//./workflows/noop//noop"
28
+ }
29
+ },
30
+ "workflows/hooks.ts": {
31
+ "writeEvent": {
32
+ "stepId": "step//./workflows/hooks//writeEvent"
33
+ }
34
+ },
35
+ "workflows/retriable-and-fatal.ts": {
36
+ "stepThatFails": {
37
+ "stepId": "step//./workflows/retriable-and-fatal//stepThatFails"
38
+ },
39
+ "stepThatThrowsRetryableError": {
40
+ "stepId": "step//./workflows/retriable-and-fatal//stepThatThrowsRetryableError"
41
+ }
42
42
  }
43
43
  },
44
44
  "workflows": {
45
- "workflows/noop.ts": {
46
- "brokenWf": {
47
- "workflowId": "workflow//./workflows/noop//brokenWf",
45
+ "workflows/null-byte.ts": {
46
+ "nullByteWorkflow": {
47
+ "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
48
48
  "graph": {
49
49
  "nodes": [
50
50
  {
51
51
  "id": "start",
52
52
  "type": "workflowStart",
53
53
  "data": {
54
- "label": "Start: brokenWf",
54
+ "label": "Start: nullByteWorkflow",
55
55
  "nodeKind": "workflow_start"
56
56
  }
57
57
  },
@@ -75,16 +75,16 @@
75
75
  }
76
76
  }
77
77
  },
78
- "workflows/retriable-and-fatal.ts": {
79
- "retryableAndFatalErrorWorkflow": {
80
- "workflowId": "workflow//./workflows/retriable-and-fatal//retryableAndFatalErrorWorkflow",
78
+ "workflows/addition.ts": {
79
+ "addition": {
80
+ "workflowId": "workflow//./workflows/addition//addition",
81
81
  "graph": {
82
82
  "nodes": [
83
83
  {
84
84
  "id": "start",
85
85
  "type": "workflowStart",
86
86
  "data": {
87
- "label": "Start: retryableAndFatalErrorWorkflow",
87
+ "label": "Start: addition",
88
88
  "nodeKind": "workflow_start"
89
89
  }
90
90
  },
@@ -108,16 +108,16 @@
108
108
  }
109
109
  }
110
110
  },
111
- "workflows/hooks.ts": {
112
- "collectWithHook": {
113
- "workflowId": "workflow//./workflows/hooks//collectWithHook",
111
+ "workflows/noop.ts": {
112
+ "brokenWf": {
113
+ "workflowId": "workflow//./workflows/noop//brokenWf",
114
114
  "graph": {
115
115
  "nodes": [
116
116
  {
117
117
  "id": "start",
118
118
  "type": "workflowStart",
119
119
  "data": {
120
- "label": "Start: collectWithHook",
120
+ "label": "Start: brokenWf",
121
121
  "nodeKind": "workflow_start"
122
122
  }
123
123
  },
@@ -141,16 +141,16 @@
141
141
  }
142
142
  }
143
143
  },
144
- "workflows/addition.ts": {
145
- "addition": {
146
- "workflowId": "workflow//./workflows/addition//addition",
144
+ "workflows/hooks.ts": {
145
+ "collectWithHook": {
146
+ "workflowId": "workflow//./workflows/hooks//collectWithHook",
147
147
  "graph": {
148
148
  "nodes": [
149
149
  {
150
150
  "id": "start",
151
151
  "type": "workflowStart",
152
152
  "data": {
153
- "label": "Start: addition",
153
+ "label": "Start: collectWithHook",
154
154
  "nodeKind": "workflow_start"
155
155
  }
156
156
  },
@@ -174,16 +174,16 @@
174
174
  }
175
175
  }
176
176
  },
177
- "workflows/null-byte.ts": {
178
- "nullByteWorkflow": {
179
- "workflowId": "workflow//./workflows/null-byte//nullByteWorkflow",
177
+ "workflows/retriable-and-fatal.ts": {
178
+ "retryableAndFatalErrorWorkflow": {
179
+ "workflowId": "workflow//./workflows/retriable-and-fatal//retryableAndFatalErrorWorkflow",
180
180
  "graph": {
181
181
  "nodes": [
182
182
  {
183
183
  "id": "start",
184
184
  "type": "workflowStart",
185
185
  "data": {
186
- "label": "Start: nullByteWorkflow",
186
+ "label": "Start: retryableAndFatalErrorWorkflow",
187
187
  "nodeKind": "workflow_start"
188
188
  }
189
189
  },