@workflow/world-testing 4.0.1-beta.50 → 4.0.1-beta.51

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.
@@ -1,11 +1,6 @@
1
1
  {
2
2
  "version": "1.0.0",
3
3
  "steps": {
4
- "workflows/addition.ts": {
5
- "add": {
6
- "stepId": "step//workflows/addition.ts//add"
7
- }
8
- },
9
4
  "workflow/dist/internal/builtins.js": {
10
5
  "__builtin_response_array_buffer": {
11
6
  "stepId": "__builtin_response_array_buffer"
@@ -17,14 +12,6 @@
17
12
  "stepId": "__builtin_response_text"
18
13
  }
19
14
  },
20
- "workflows/retriable-and-fatal.ts": {
21
- "stepThatFails": {
22
- "stepId": "step//workflows/retriable-and-fatal.ts//stepThatFails"
23
- },
24
- "stepThatThrowsRetryableError": {
25
- "stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
26
- }
27
- },
28
15
  "workflows/hooks.ts": {
29
16
  "writeEvent": {
30
17
  "stepId": "step//workflows/hooks.ts//writeEvent"
@@ -40,23 +27,36 @@
40
27
  "stepId": "step//workflows/noop.ts//noop"
41
28
  }
42
29
  },
30
+ "workflows/retriable-and-fatal.ts": {
31
+ "stepThatFails": {
32
+ "stepId": "step//workflows/retriable-and-fatal.ts//stepThatFails"
33
+ },
34
+ "stepThatThrowsRetryableError": {
35
+ "stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
36
+ }
37
+ },
43
38
  "workflow/dist/stdlib.js": {
44
39
  "fetch": {
45
40
  "stepId": "step//workflow/dist/stdlib.js//fetch"
46
41
  }
42
+ },
43
+ "workflows/addition.ts": {
44
+ "add": {
45
+ "stepId": "step//workflows/addition.ts//add"
46
+ }
47
47
  }
48
48
  },
49
49
  "workflows": {
50
- "workflows/addition.ts": {
51
- "addition": {
52
- "workflowId": "workflow//workflows/addition.ts//addition",
50
+ "workflows/hooks.ts": {
51
+ "collectWithHook": {
52
+ "workflowId": "workflow//workflows/hooks.ts//collectWithHook",
53
53
  "graph": {
54
54
  "nodes": [
55
55
  {
56
56
  "id": "start",
57
57
  "type": "workflowStart",
58
58
  "data": {
59
- "label": "Start: addition",
59
+ "label": "Start: collectWithHook",
60
60
  "nodeKind": "workflow_start"
61
61
  }
62
62
  },
@@ -64,9 +64,22 @@
64
64
  "id": "node_0",
65
65
  "type": "step",
66
66
  "data": {
67
- "label": "add",
67
+ "label": "writeEvent",
68
68
  "nodeKind": "step",
69
- "stepId": "step//workflows/addition.ts//add"
69
+ "stepId": "step//workflows/hooks.ts//writeEvent"
70
+ }
71
+ },
72
+ {
73
+ "id": "node_1",
74
+ "type": "step",
75
+ "data": {
76
+ "label": "writeEvent",
77
+ "nodeKind": "step",
78
+ "stepId": "step//workflows/hooks.ts//writeEvent"
79
+ },
80
+ "metadata": {
81
+ "loopId": "loop_0",
82
+ "loopIsAwait": true
70
83
  }
71
84
  },
72
85
  {
@@ -86,8 +99,20 @@
86
99
  "type": "default"
87
100
  },
88
101
  {
89
- "id": "e_node_0_end",
102
+ "id": "e_node_1_back_node_1",
103
+ "source": "node_1",
104
+ "target": "node_1",
105
+ "type": "loop"
106
+ },
107
+ {
108
+ "id": "e_node_0_node_1",
90
109
  "source": "node_0",
110
+ "target": "node_1",
111
+ "type": "default"
112
+ },
113
+ {
114
+ "id": "e_node_1_end",
115
+ "source": "node_1",
91
116
  "target": "end",
92
117
  "type": "default"
93
118
  }
@@ -95,16 +120,16 @@
95
120
  }
96
121
  }
97
122
  },
98
- "workflows/retriable-and-fatal.ts": {
99
- "retryableAndFatalErrorWorkflow": {
100
- "workflowId": "workflow//workflows/retriable-and-fatal.ts//retryableAndFatalErrorWorkflow",
123
+ "workflows/null-byte.ts": {
124
+ "nullByteWorkflow": {
125
+ "workflowId": "workflow//workflows/null-byte.ts//nullByteWorkflow",
101
126
  "graph": {
102
127
  "nodes": [
103
128
  {
104
129
  "id": "start",
105
130
  "type": "workflowStart",
106
131
  "data": {
107
- "label": "Start: retryableAndFatalErrorWorkflow",
132
+ "label": "Start: nullByteWorkflow",
108
133
  "nodeKind": "workflow_start"
109
134
  }
110
135
  },
@@ -112,9 +137,9 @@
112
137
  "id": "node_0",
113
138
  "type": "step",
114
139
  "data": {
115
- "label": "stepThatThrowsRetryableError",
140
+ "label": "nullByteStep",
116
141
  "nodeKind": "step",
117
- "stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
142
+ "stepId": "step//workflows/null-byte.ts//nullByteStep"
118
143
  }
119
144
  },
120
145
  {
@@ -143,16 +168,16 @@
143
168
  }
144
169
  }
145
170
  },
146
- "workflows/hooks.ts": {
147
- "collectWithHook": {
148
- "workflowId": "workflow//workflows/hooks.ts//collectWithHook",
171
+ "workflows/noop.ts": {
172
+ "brokenWf": {
173
+ "workflowId": "workflow//workflows/noop.ts//brokenWf",
149
174
  "graph": {
150
175
  "nodes": [
151
176
  {
152
177
  "id": "start",
153
178
  "type": "workflowStart",
154
179
  "data": {
155
- "label": "Start: collectWithHook",
180
+ "label": "Start: brokenWf",
156
181
  "nodeKind": "workflow_start"
157
182
  }
158
183
  },
@@ -160,22 +185,18 @@
160
185
  "id": "node_0",
161
186
  "type": "step",
162
187
  "data": {
163
- "label": "writeEvent",
188
+ "label": "noop",
164
189
  "nodeKind": "step",
165
- "stepId": "step//workflows/hooks.ts//writeEvent"
190
+ "stepId": "step//workflows/noop.ts//noop"
166
191
  }
167
192
  },
168
193
  {
169
194
  "id": "node_1",
170
195
  "type": "step",
171
196
  "data": {
172
- "label": "writeEvent",
197
+ "label": "noop",
173
198
  "nodeKind": "step",
174
- "stepId": "step//workflows/hooks.ts//writeEvent"
175
- },
176
- "metadata": {
177
- "loopId": "loop_0",
178
- "loopIsAwait": true
199
+ "stepId": "step//workflows/noop.ts//noop"
179
200
  }
180
201
  },
181
202
  {
@@ -194,12 +215,6 @@
194
215
  "target": "node_0",
195
216
  "type": "default"
196
217
  },
197
- {
198
- "id": "e_node_1_back_node_1",
199
- "source": "node_1",
200
- "target": "node_1",
201
- "type": "loop"
202
- },
203
218
  {
204
219
  "id": "e_node_0_node_1",
205
220
  "source": "node_0",
@@ -216,16 +231,16 @@
216
231
  }
217
232
  }
218
233
  },
219
- "workflows/null-byte.ts": {
220
- "nullByteWorkflow": {
221
- "workflowId": "workflow//workflows/null-byte.ts//nullByteWorkflow",
234
+ "workflows/retriable-and-fatal.ts": {
235
+ "retryableAndFatalErrorWorkflow": {
236
+ "workflowId": "workflow//workflows/retriable-and-fatal.ts//retryableAndFatalErrorWorkflow",
222
237
  "graph": {
223
238
  "nodes": [
224
239
  {
225
240
  "id": "start",
226
241
  "type": "workflowStart",
227
242
  "data": {
228
- "label": "Start: nullByteWorkflow",
243
+ "label": "Start: retryableAndFatalErrorWorkflow",
229
244
  "nodeKind": "workflow_start"
230
245
  }
231
246
  },
@@ -233,9 +248,9 @@
233
248
  "id": "node_0",
234
249
  "type": "step",
235
250
  "data": {
236
- "label": "nullByteStep",
251
+ "label": "stepThatThrowsRetryableError",
237
252
  "nodeKind": "step",
238
- "stepId": "step//workflows/null-byte.ts//nullByteStep"
253
+ "stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
239
254
  }
240
255
  },
241
256
  {
@@ -264,16 +279,16 @@
264
279
  }
265
280
  }
266
281
  },
267
- "workflows/noop.ts": {
268
- "brokenWf": {
269
- "workflowId": "workflow//workflows/noop.ts//brokenWf",
282
+ "workflows/addition.ts": {
283
+ "addition": {
284
+ "workflowId": "workflow//workflows/addition.ts//addition",
270
285
  "graph": {
271
286
  "nodes": [
272
287
  {
273
288
  "id": "start",
274
289
  "type": "workflowStart",
275
290
  "data": {
276
- "label": "Start: brokenWf",
291
+ "label": "Start: addition",
277
292
  "nodeKind": "workflow_start"
278
293
  }
279
294
  },
@@ -281,18 +296,9 @@
281
296
  "id": "node_0",
282
297
  "type": "step",
283
298
  "data": {
284
- "label": "noop",
285
- "nodeKind": "step",
286
- "stepId": "step//workflows/noop.ts//noop"
287
- }
288
- },
289
- {
290
- "id": "node_1",
291
- "type": "step",
292
- "data": {
293
- "label": "noop",
299
+ "label": "add",
294
300
  "nodeKind": "step",
295
- "stepId": "step//workflows/noop.ts//noop"
301
+ "stepId": "step//workflows/addition.ts//add"
296
302
  }
297
303
  },
298
304
  {
@@ -312,14 +318,8 @@
312
318
  "type": "default"
313
319
  },
314
320
  {
315
- "id": "e_node_0_node_1",
321
+ "id": "e_node_0_end",
316
322
  "source": "node_0",
317
- "target": "node_1",
318
- "type": "default"
319
- },
320
- {
321
- "id": "e_node_1_end",
322
- "source": "node_1",
323
323
  "target": "end",
324
324
  "type": "default"
325
325
  }
@@ -24539,19 +24539,6 @@ async function addition(num, num2) {
24539
24539
  __name(addition, "addition");
24540
24540
  addition.workflowId = "workflow//workflows/addition.ts//addition";
24541
24541
  registerStepFunction("step//workflows/addition.ts//add", add);
24542
- // workflows/noop.ts
24543
- var count = 0;
24544
- async function noop(_i) {
24545
- count++;
24546
- return count;
24547
- }
24548
- __name(noop, "noop");
24549
- async function brokenWf() {
24550
- throw new Error("You attempted to execute workflow brokenWf function directly. To start a workflow, use start(brokenWf) from workflow/api");
24551
- }
24552
- __name(brokenWf, "brokenWf");
24553
- brokenWf.workflowId = "workflow//workflows/noop.ts//brokenWf";
24554
- registerStepFunction("step//workflows/noop.ts//noop", noop);
24555
24542
  // ../utils/dist/pluralize.js
24556
24543
  function pluralize(singular, plural, count2) {
24557
24544
  return count2 === 1 ? singular : plural;
@@ -25841,6 +25828,9 @@ async function resolveBaseUrl(config3) {
25841
25828
  if (config3.baseUrl) {
25842
25829
  return config3.baseUrl;
25843
25830
  }
25831
+ if (process.env.WORKFLOW_LOCAL_BASE_URL) {
25832
+ return process.env.WORKFLOW_LOCAL_BASE_URL;
25833
+ }
25844
25834
  if (typeof config3.port === "number") {
25845
25835
  return `http://localhost:${config3.port}`;
25846
25836
  }
@@ -41714,6 +41704,7 @@ var StepSchema = external_exports.object({
41714
41704
  var import_async_sema = __toESM(require_lib(), 1);
41715
41705
  var import_undici = __toESM(require_undici(), 1);
41716
41706
  var LOCAL_QUEUE_MAX_VISIBILITY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY ?? "0", 10) || Infinity;
41707
+ var MAX_SAFE_TIMEOUT_MS = 2147483647;
41717
41708
  var DEFAULT_CONCURRENCY_LIMIT = 100;
41718
41709
  var WORKFLOW_LOCAL_QUEUE_CONCURRENCY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY ?? "0", 10) || DEFAULT_CONCURRENCY_LIMIT;
41719
41710
  var httpAgent = new import_undici.Agent({
@@ -41785,7 +41776,8 @@ function createQueue(config3) {
41785
41776
  if (response.status === 503) {
41786
41777
  try {
41787
41778
  const timeoutSeconds = Number(JSON.parse(text).timeoutSeconds);
41788
- await (0, import_promises2.setTimeout)(timeoutSeconds * 1e3);
41779
+ const timeoutMs = Math.min(timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
41780
+ await (0, import_promises2.setTimeout)(timeoutMs);
41789
41781
  defaultRetriesLeft++;
41790
41782
  continue;
41791
41783
  }
@@ -41890,6 +41882,31 @@ var import_node_fs2 = require("node:fs");
41890
41882
  var import_node_path2 = __toESM(require("node:path"), 1);
41891
41883
  var ulid3 = monotonicFactory(() => Math.random());
41892
41884
  var Ulid = external_exports.string().ulid();
41885
+ var isWindows = process.platform === "win32";
41886
+ async function withWindowsRetry(fn, maxRetries = 5) {
41887
+ if (!isWindows)
41888
+ return fn();
41889
+ const retryableErrors = [
41890
+ "EPERM",
41891
+ "EBUSY",
41892
+ "EACCES"
41893
+ ];
41894
+ const baseDelayMs = 10;
41895
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
41896
+ try {
41897
+ return await fn();
41898
+ }
41899
+ catch (error45) {
41900
+ const isRetryable = attempt < maxRetries && retryableErrors.includes(error45.code);
41901
+ if (!isRetryable)
41902
+ throw error45;
41903
+ const delay = baseDelayMs * Math.pow(2, attempt) + Math.random() * baseDelayMs;
41904
+ await new Promise((resolve2) => setTimeout(resolve2, delay));
41905
+ }
41906
+ }
41907
+ throw new Error("Retry loop exited unexpectedly");
41908
+ }
41909
+ __name(withWindowsRetry, "withWindowsRetry");
41893
41910
  var createdFilesCache = /* @__PURE__ */ new Set();
41894
41911
  function ulidToDate(maybeUlid) {
41895
41912
  const ulid4 = Ulid.safeParse(maybeUlid);
@@ -41939,12 +41956,12 @@ async function write(filePath, data, opts) {
41939
41956
  await ensureDir(import_node_path2.default.dirname(filePath));
41940
41957
  await import_node_fs2.promises.writeFile(tempPath, data);
41941
41958
  tempFileCreated = true;
41942
- await import_node_fs2.promises.rename(tempPath, filePath);
41959
+ await withWindowsRetry(() => import_node_fs2.promises.rename(tempPath, filePath));
41943
41960
  createdFilesCache.add(filePath);
41944
41961
  }
41945
41962
  catch (error45) {
41946
41963
  if (tempFileCreated) {
41947
- await import_node_fs2.promises.unlink(tempPath).catch(() => {
41964
+ await withWindowsRetry(() => import_node_fs2.promises.unlink(tempPath), 3).catch(() => {
41948
41965
  });
41949
41966
  }
41950
41967
  throw error45;
@@ -42747,7 +42764,7 @@ __name(createLocalWorld, "createLocalWorld");
42747
42764
  var import_node_os = __toESM(require("node:os"), 1);
42748
42765
  var import_oidc2 = __toESM(require_dist(), 1);
42749
42766
  // ../world-vercel/dist/version.js
42750
- var version2 = "4.0.1-beta.27";
42767
+ var version2 = "4.0.1-beta.28";
42751
42768
  // ../world-vercel/dist/utils.js
42752
42769
  var DEFAULT_RESOLVE_DATA_OPTION2 = "all";
42753
42770
  function dateToStringReplacer(_key, value) {
@@ -42911,6 +42928,10 @@ function createQueue2(config3) {
42911
42928
  headers: Object.fromEntries(headers.entries())
42912
42929
  });
42913
42930
  const queue = /* @__PURE__ */ __name(async (queueName, payload, opts) => {
42931
+ const deploymentId = opts?.deploymentId ?? process.env.VERCEL_DEPLOYMENT_ID;
42932
+ if (!deploymentId) {
42933
+ throw new Error("No deploymentId provided and VERCEL_DEPLOYMENT_ID environment variable is not set. Queue messages require a deployment ID to route correctly. Either set VERCEL_DEPLOYMENT_ID or provide deploymentId in options.");
42934
+ }
42914
42935
  const hasEncoder = typeof MessageWrapper.encode === "function";
42915
42936
  if (!hasEncoder) {
42916
42937
  console.warn("Using zod v3 compatibility mode for queue() calls - this may not work as expected");
@@ -44478,6 +44499,19 @@ async function writeEvent(writable, event, payload) {
44478
44499
  }
44479
44500
  __name(writeEvent, "writeEvent");
44480
44501
  registerStepFunction("step//workflows/hooks.ts//writeEvent", writeEvent);
44502
+ // workflows/noop.ts
44503
+ var count = 0;
44504
+ async function noop(_i) {
44505
+ count++;
44506
+ return count;
44507
+ }
44508
+ __name(noop, "noop");
44509
+ async function brokenWf() {
44510
+ throw new Error("You attempted to execute workflow brokenWf function directly. To start a workflow, use start(brokenWf) from workflow/api");
44511
+ }
44512
+ __name(brokenWf, "brokenWf");
44513
+ brokenWf.workflowId = "workflow//workflows/noop.ts//brokenWf";
44514
+ registerStepFunction("step//workflows/noop.ts//noop", noop);
44481
44515
  // workflows/null-byte.ts
44482
44516
  async function nullByteStep() {
44483
44517
  return "null byte \0";