@workflow/world-testing 4.0.1-beta.21 → 4.0.1-beta.23
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/.well-known/workflow/v1/flow.js +341 -92
- package/dist/.well-known/workflow/v1/flow.js.map +1 -1
- package/dist/.well-known/workflow/v1/manifest.debug.json +31 -31
- package/dist/.well-known/workflow/v1/step.js +312 -68
- package/dist/.well-known/workflow/v1/step.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"steps": {
|
|
3
|
+
"workflows/addition.ts": {
|
|
4
|
+
"add": {
|
|
5
|
+
"stepId": "step//workflows/addition.ts//add"
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
"workflows/null-byte.ts": {
|
|
9
|
+
"nullByteStep": {
|
|
10
|
+
"stepId": "step//workflows/null-byte.ts//nullByteStep"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"workflows/retriable-and-fatal.ts": {
|
|
14
|
+
"stepThatFails": {
|
|
15
|
+
"stepId": "step//workflows/retriable-and-fatal.ts//stepThatFails"
|
|
16
|
+
},
|
|
17
|
+
"stepThatThrowsRetryableError": {
|
|
18
|
+
"stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
3
21
|
"workflow/dist/internal/builtins.js": {
|
|
4
22
|
"__builtin_response_array_buffer": {
|
|
5
23
|
"stepId": "__builtin_response_array_buffer"
|
|
@@ -11,51 +29,33 @@
|
|
|
11
29
|
"stepId": "__builtin_response_text"
|
|
12
30
|
}
|
|
13
31
|
},
|
|
14
|
-
"workflows/null-byte.ts": {
|
|
15
|
-
"nullByteStep": {
|
|
16
|
-
"stepId": "step//workflows/null-byte.ts//nullByteStep"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"workflows/addition.ts": {
|
|
20
|
-
"add": {
|
|
21
|
-
"stepId": "step//workflows/addition.ts//add"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
32
|
"workflow/dist/stdlib.js": {
|
|
25
33
|
"fetch": {
|
|
26
34
|
"stepId": "step//workflow/dist/stdlib.js//fetch"
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
|
-
"workflows/noop.ts": {
|
|
30
|
-
"noop": {
|
|
31
|
-
"stepId": "step//workflows/noop.ts//noop"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"workflows/retriable-and-fatal.ts": {
|
|
35
|
-
"stepThatFails": {
|
|
36
|
-
"stepId": "step//workflows/retriable-and-fatal.ts//stepThatFails"
|
|
37
|
-
},
|
|
38
|
-
"stepThatThrowsRetryableError": {
|
|
39
|
-
"stepId": "step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
37
|
"workflows/hooks.ts": {
|
|
43
38
|
"writeEvent": {
|
|
44
39
|
"stepId": "step//workflows/hooks.ts//writeEvent"
|
|
45
40
|
}
|
|
41
|
+
},
|
|
42
|
+
"workflows/noop.ts": {
|
|
43
|
+
"noop": {
|
|
44
|
+
"stepId": "step//workflows/noop.ts//noop"
|
|
45
|
+
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"workflows": {
|
|
49
|
+
"workflows/null-byte.ts": {
|
|
50
|
+
"nullByteWorkflow": {
|
|
51
|
+
"workflowId": "workflow//workflows/null-byte.ts//nullByteWorkflow"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
49
54
|
"workflows/addition.ts": {
|
|
50
55
|
"addition": {
|
|
51
56
|
"workflowId": "workflow//workflows/addition.ts//addition"
|
|
52
57
|
}
|
|
53
58
|
},
|
|
54
|
-
"workflows/hooks.ts": {
|
|
55
|
-
"collectWithHook": {
|
|
56
|
-
"workflowId": "workflow//workflows/hooks.ts//collectWithHook"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
59
|
"workflows/noop.ts": {
|
|
60
60
|
"brokenWf": {
|
|
61
61
|
"workflowId": "workflow//workflows/noop.ts//brokenWf"
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"workflowId": "workflow//workflows/retriable-and-fatal.ts//retryableAndFatalErrorWorkflow"
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"workflows/
|
|
70
|
-
"
|
|
71
|
-
"workflowId": "workflow//workflows/
|
|
69
|
+
"workflows/hooks.ts": {
|
|
70
|
+
"collectWithHook": {
|
|
71
|
+
"workflowId": "workflow//workflows/hooks.ts//collectWithHook"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -20591,6 +20591,194 @@ var require_undici = __commonJS({
|
|
|
20591
20591
|
module2.exports.EventSource = EventSource;
|
|
20592
20592
|
}
|
|
20593
20593
|
});
|
|
20594
|
+
// ../../node_modules/.pnpm/async-sema@3.1.1/node_modules/async-sema/lib/index.js
|
|
20595
|
+
var require_lib = __commonJS({
|
|
20596
|
+
"../../node_modules/.pnpm/async-sema@3.1.1/node_modules/async-sema/lib/index.js"(exports2) {
|
|
20597
|
+
"use strict";
|
|
20598
|
+
var __importDefault = exports2 && exports2.__importDefault || function (mod) {
|
|
20599
|
+
return mod && mod.__esModule ? mod : {
|
|
20600
|
+
"default": mod
|
|
20601
|
+
};
|
|
20602
|
+
};
|
|
20603
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
20604
|
+
value: true
|
|
20605
|
+
});
|
|
20606
|
+
exports2.RateLimit = exports2.Sema = void 0;
|
|
20607
|
+
var events_1 = __importDefault(require("events"));
|
|
20608
|
+
function arrayMove(src, srcIndex, dst, dstIndex, len) {
|
|
20609
|
+
for (let j = 0; j < len; ++j) {
|
|
20610
|
+
dst[j + dstIndex] = src[j + srcIndex];
|
|
20611
|
+
src[j + srcIndex] = void 0;
|
|
20612
|
+
}
|
|
20613
|
+
}
|
|
20614
|
+
__name(arrayMove, "arrayMove");
|
|
20615
|
+
function pow2AtLeast(n2) {
|
|
20616
|
+
n2 = n2 >>> 0;
|
|
20617
|
+
n2 = n2 - 1;
|
|
20618
|
+
n2 = n2 | n2 >> 1;
|
|
20619
|
+
n2 = n2 | n2 >> 2;
|
|
20620
|
+
n2 = n2 | n2 >> 4;
|
|
20621
|
+
n2 = n2 | n2 >> 8;
|
|
20622
|
+
n2 = n2 | n2 >> 16;
|
|
20623
|
+
return n2 + 1;
|
|
20624
|
+
}
|
|
20625
|
+
__name(pow2AtLeast, "pow2AtLeast");
|
|
20626
|
+
function getCapacity(capacity) {
|
|
20627
|
+
return pow2AtLeast(Math.min(Math.max(16, capacity), 1073741824));
|
|
20628
|
+
}
|
|
20629
|
+
__name(getCapacity, "getCapacity");
|
|
20630
|
+
var Deque = class {
|
|
20631
|
+
static {
|
|
20632
|
+
__name(this, "Deque");
|
|
20633
|
+
}
|
|
20634
|
+
constructor(capacity) {
|
|
20635
|
+
this._capacity = getCapacity(capacity);
|
|
20636
|
+
this._length = 0;
|
|
20637
|
+
this._front = 0;
|
|
20638
|
+
this.arr = [];
|
|
20639
|
+
}
|
|
20640
|
+
push(item) {
|
|
20641
|
+
const length = this._length;
|
|
20642
|
+
this.checkCapacity(length + 1);
|
|
20643
|
+
const i2 = this._front + length & this._capacity - 1;
|
|
20644
|
+
this.arr[i2] = item;
|
|
20645
|
+
this._length = length + 1;
|
|
20646
|
+
return length + 1;
|
|
20647
|
+
}
|
|
20648
|
+
pop() {
|
|
20649
|
+
const length = this._length;
|
|
20650
|
+
if (length === 0) {
|
|
20651
|
+
return void 0;
|
|
20652
|
+
}
|
|
20653
|
+
const i2 = this._front + length - 1 & this._capacity - 1;
|
|
20654
|
+
const ret = this.arr[i2];
|
|
20655
|
+
this.arr[i2] = void 0;
|
|
20656
|
+
this._length = length - 1;
|
|
20657
|
+
return ret;
|
|
20658
|
+
}
|
|
20659
|
+
shift() {
|
|
20660
|
+
const length = this._length;
|
|
20661
|
+
if (length === 0) {
|
|
20662
|
+
return void 0;
|
|
20663
|
+
}
|
|
20664
|
+
const front = this._front;
|
|
20665
|
+
const ret = this.arr[front];
|
|
20666
|
+
this.arr[front] = void 0;
|
|
20667
|
+
this._front = front + 1 & this._capacity - 1;
|
|
20668
|
+
this._length = length - 1;
|
|
20669
|
+
return ret;
|
|
20670
|
+
}
|
|
20671
|
+
get length() {
|
|
20672
|
+
return this._length;
|
|
20673
|
+
}
|
|
20674
|
+
checkCapacity(size) {
|
|
20675
|
+
if (this._capacity < size) {
|
|
20676
|
+
this.resizeTo(getCapacity(this._capacity * 1.5 + 16));
|
|
20677
|
+
}
|
|
20678
|
+
}
|
|
20679
|
+
resizeTo(capacity) {
|
|
20680
|
+
const oldCapacity = this._capacity;
|
|
20681
|
+
this._capacity = capacity;
|
|
20682
|
+
const front = this._front;
|
|
20683
|
+
const length = this._length;
|
|
20684
|
+
if (front + length > oldCapacity) {
|
|
20685
|
+
const moveItemsCount = front + length & oldCapacity - 1;
|
|
20686
|
+
arrayMove(this.arr, 0, this.arr, oldCapacity, moveItemsCount);
|
|
20687
|
+
}
|
|
20688
|
+
}
|
|
20689
|
+
};
|
|
20690
|
+
var ReleaseEmitter = class extends events_1.default {
|
|
20691
|
+
static {
|
|
20692
|
+
__name(this, "ReleaseEmitter");
|
|
20693
|
+
}
|
|
20694
|
+
};
|
|
20695
|
+
function isFn(x) {
|
|
20696
|
+
return typeof x === "function";
|
|
20697
|
+
}
|
|
20698
|
+
__name(isFn, "isFn");
|
|
20699
|
+
function defaultInit() {
|
|
20700
|
+
return "1";
|
|
20701
|
+
}
|
|
20702
|
+
__name(defaultInit, "defaultInit");
|
|
20703
|
+
var Sema2 = class {
|
|
20704
|
+
static {
|
|
20705
|
+
__name(this, "Sema");
|
|
20706
|
+
}
|
|
20707
|
+
constructor(nr, { initFn = defaultInit, pauseFn, resumeFn, capacity = 10 } = {}) {
|
|
20708
|
+
if (isFn(pauseFn) !== isFn(resumeFn)) {
|
|
20709
|
+
throw new Error("pauseFn and resumeFn must be both set for pausing");
|
|
20710
|
+
}
|
|
20711
|
+
this.nrTokens = nr;
|
|
20712
|
+
this.free = new Deque(nr);
|
|
20713
|
+
this.waiting = new Deque(capacity);
|
|
20714
|
+
this.releaseEmitter = new ReleaseEmitter();
|
|
20715
|
+
this.noTokens = initFn === defaultInit;
|
|
20716
|
+
this.pauseFn = pauseFn;
|
|
20717
|
+
this.resumeFn = resumeFn;
|
|
20718
|
+
this.paused = false;
|
|
20719
|
+
this.releaseEmitter.on("release", (token) => {
|
|
20720
|
+
const p = this.waiting.shift();
|
|
20721
|
+
if (p) {
|
|
20722
|
+
p.resolve(token);
|
|
20723
|
+
}
|
|
20724
|
+
else {
|
|
20725
|
+
if (this.resumeFn && this.paused) {
|
|
20726
|
+
this.paused = false;
|
|
20727
|
+
this.resumeFn();
|
|
20728
|
+
}
|
|
20729
|
+
this.free.push(token);
|
|
20730
|
+
}
|
|
20731
|
+
});
|
|
20732
|
+
for (let i2 = 0; i2 < nr; i2++) {
|
|
20733
|
+
this.free.push(initFn());
|
|
20734
|
+
}
|
|
20735
|
+
}
|
|
20736
|
+
tryAcquire() {
|
|
20737
|
+
return this.free.pop();
|
|
20738
|
+
}
|
|
20739
|
+
async acquire() {
|
|
20740
|
+
let token = this.tryAcquire();
|
|
20741
|
+
if (token !== void 0) {
|
|
20742
|
+
return token;
|
|
20743
|
+
}
|
|
20744
|
+
return new Promise((resolve2, reject) => {
|
|
20745
|
+
if (this.pauseFn && !this.paused) {
|
|
20746
|
+
this.paused = true;
|
|
20747
|
+
this.pauseFn();
|
|
20748
|
+
}
|
|
20749
|
+
this.waiting.push({
|
|
20750
|
+
resolve: resolve2,
|
|
20751
|
+
reject
|
|
20752
|
+
});
|
|
20753
|
+
});
|
|
20754
|
+
}
|
|
20755
|
+
release(token) {
|
|
20756
|
+
this.releaseEmitter.emit("release", this.noTokens ? "1" : token);
|
|
20757
|
+
}
|
|
20758
|
+
drain() {
|
|
20759
|
+
const a2 = new Array(this.nrTokens);
|
|
20760
|
+
for (let i2 = 0; i2 < this.nrTokens; i2++) {
|
|
20761
|
+
a2[i2] = this.acquire();
|
|
20762
|
+
}
|
|
20763
|
+
return Promise.all(a2);
|
|
20764
|
+
}
|
|
20765
|
+
nrWaiting() {
|
|
20766
|
+
return this.waiting.length;
|
|
20767
|
+
}
|
|
20768
|
+
};
|
|
20769
|
+
exports2.Sema = Sema2;
|
|
20770
|
+
function RateLimit(rps, { timeUnit = 1e3, uniformDistribution = false } = {}) {
|
|
20771
|
+
const sema = new Sema2(uniformDistribution ? 1 : rps);
|
|
20772
|
+
const delay = uniformDistribution ? timeUnit / rps : timeUnit;
|
|
20773
|
+
return /* @__PURE__ */ __name(async function rl() {
|
|
20774
|
+
await sema.acquire();
|
|
20775
|
+
setTimeout(() => sema.release(), delay);
|
|
20776
|
+
}, "rl");
|
|
20777
|
+
}
|
|
20778
|
+
__name(RateLimit, "RateLimit");
|
|
20779
|
+
exports2.RateLimit = RateLimit;
|
|
20780
|
+
}
|
|
20781
|
+
});
|
|
20594
20782
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
20595
20783
|
var require_globalThis = __commonJS({
|
|
20596
20784
|
"../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js"(exports2) {
|
|
@@ -23982,6 +24170,9 @@ __export(virtual_entry_exports, {
|
|
|
23982
24170
|
POST: () => stepEntrypoint
|
|
23983
24171
|
});
|
|
23984
24172
|
module.exports = __toCommonJS(virtual_entry_exports);
|
|
24173
|
+
// ../core/dist/step/context-storage.js
|
|
24174
|
+
var import_node_async_hooks = require("node:async_hooks");
|
|
24175
|
+
var contextStorage = /* @__PURE__ */ new import_node_async_hooks.AsyncLocalStorage();
|
|
23985
24176
|
// ../core/dist/private.js
|
|
23986
24177
|
var registeredSteps = /* @__PURE__ */ new Map();
|
|
23987
24178
|
function registerStepFunction(stepId, stepFn) {
|
|
@@ -24008,12 +24199,14 @@ __name(__builtin_response_text, "__builtin_response_text");
|
|
|
24008
24199
|
registerStepFunction("__builtin_response_array_buffer", __builtin_response_array_buffer);
|
|
24009
24200
|
registerStepFunction("__builtin_response_json", __builtin_response_json);
|
|
24010
24201
|
registerStepFunction("__builtin_response_text", __builtin_response_text);
|
|
24011
|
-
// workflows/
|
|
24012
|
-
|
|
24013
|
-
|
|
24202
|
+
// workflows/noop.ts
|
|
24203
|
+
var count = 0;
|
|
24204
|
+
async function noop(_i) {
|
|
24205
|
+
count++;
|
|
24206
|
+
return count;
|
|
24014
24207
|
}
|
|
24015
|
-
__name(
|
|
24016
|
-
registerStepFunction("step//workflows/
|
|
24208
|
+
__name(noop, "noop");
|
|
24209
|
+
registerStepFunction("step//workflows/noop.ts//noop", noop);
|
|
24017
24210
|
// ../utils/dist/index.js
|
|
24018
24211
|
var import_ms = __toESM(require_ms(), 1);
|
|
24019
24212
|
function once(fn) {
|
|
@@ -26571,13 +26764,13 @@ var handleSendStrict = /* @__PURE__ */ __name(({ anyProcess, channel, isSubproce
|
|
|
26571
26764
|
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
26572
26765
|
const hasListeners = hasMessageListeners(anyProcess, ipcEmitter);
|
|
26573
26766
|
return {
|
|
26574
|
-
id:
|
|
26767
|
+
id: count2++,
|
|
26575
26768
|
type: REQUEST_TYPE,
|
|
26576
26769
|
message,
|
|
26577
26770
|
hasListeners
|
|
26578
26771
|
};
|
|
26579
26772
|
}, "handleSendStrict");
|
|
26580
|
-
var
|
|
26773
|
+
var count2 = 0n;
|
|
26581
26774
|
var validateStrictDeadlock = /* @__PURE__ */ __name((outgoingMessages, wrappedMessage) => {
|
|
26582
26775
|
if (wrappedMessage?.type !== REQUEST_TYPE || wrappedMessage.hasListeners) {
|
|
26583
26776
|
return;
|
|
@@ -27438,7 +27631,7 @@ var MaxBufferError = class extends Error {
|
|
|
27438
27631
|
};
|
|
27439
27632
|
// ../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/utils.js
|
|
27440
27633
|
var identity2 = /* @__PURE__ */ __name((value) => value, "identity");
|
|
27441
|
-
var
|
|
27634
|
+
var noop2 = /* @__PURE__ */ __name(() => void 0, "noop");
|
|
27442
27635
|
var getContentsProperty = /* @__PURE__ */ __name(({ contents }) => contents, "getContentsProperty");
|
|
27443
27636
|
var throwObjectStream = /* @__PURE__ */ __name((chunk) => {
|
|
27444
27637
|
throw new Error(`Streams in object mode are not supported: ${String(chunk)}`);
|
|
@@ -27468,9 +27661,9 @@ var arrayMethods = {
|
|
|
27468
27661
|
others: identity2
|
|
27469
27662
|
},
|
|
27470
27663
|
getSize: increment,
|
|
27471
|
-
truncateChunk:
|
|
27664
|
+
truncateChunk: noop2,
|
|
27472
27665
|
addChunk: addArrayChunk,
|
|
27473
|
-
getFinalChunk:
|
|
27666
|
+
getFinalChunk: noop2,
|
|
27474
27667
|
finalize: getContentsProperty
|
|
27475
27668
|
};
|
|
27476
27669
|
// ../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/array-buffer.js
|
|
@@ -27527,7 +27720,7 @@ var arrayBufferMethods = {
|
|
|
27527
27720
|
getSize: getLengthProperty,
|
|
27528
27721
|
truncateChunk: truncateArrayBufferChunk,
|
|
27529
27722
|
addChunk: addArrayBufferChunk,
|
|
27530
|
-
getFinalChunk:
|
|
27723
|
+
getFinalChunk: noop2,
|
|
27531
27724
|
finalize: finalizeArrayBuffer
|
|
27532
27725
|
};
|
|
27533
27726
|
// ../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/string.js
|
|
@@ -30194,11 +30387,11 @@ var abortStream = /* @__PURE__ */ __name((stream) => {
|
|
|
30194
30387
|
}, "abortStream");
|
|
30195
30388
|
var errorStream = /* @__PURE__ */ __name((stream, error45) => {
|
|
30196
30389
|
if (!stream.destroyed) {
|
|
30197
|
-
stream.once("error",
|
|
30390
|
+
stream.once("error", noop3);
|
|
30198
30391
|
stream.destroy(error45);
|
|
30199
30392
|
}
|
|
30200
30393
|
}, "errorStream");
|
|
30201
|
-
var
|
|
30394
|
+
var noop3 = /* @__PURE__ */ __name(() => {
|
|
30202
30395
|
}, "noop");
|
|
30203
30396
|
var updateMaxListeners = /* @__PURE__ */ __name((passThroughStream, increment2) => {
|
|
30204
30397
|
const maxListeners = passThroughStream.getMaxListeners();
|
|
@@ -47898,13 +48091,17 @@ function monotonicFactory(prng) {
|
|
|
47898
48091
|
__name(monotonicFactory, "monotonicFactory");
|
|
47899
48092
|
// ../world-local/dist/queue.js
|
|
47900
48093
|
var import_undici = __toESM(require_undici(), 1);
|
|
48094
|
+
var import_async_sema = __toESM(require_lib(), 1);
|
|
47901
48095
|
var LOCAL_QUEUE_MAX_VISIBILITY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY ?? "0", 10) || Infinity;
|
|
48096
|
+
var DEFAULT_CONCURRENCY_LIMIT = 20;
|
|
48097
|
+
var WORKFLOW_LOCAL_QUEUE_CONCURRENCY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY ?? "0", 10) || DEFAULT_CONCURRENCY_LIMIT;
|
|
47902
48098
|
var httpAgent = new import_undici.Agent({
|
|
47903
48099
|
headersTimeout: 0
|
|
47904
48100
|
});
|
|
47905
48101
|
function createQueue(config3) {
|
|
47906
48102
|
const transport = new JsonTransport();
|
|
47907
48103
|
const generateId = monotonicFactory();
|
|
48104
|
+
const semaphore = new import_async_sema.Sema(WORKFLOW_LOCAL_QUEUE_CONCURRENCY);
|
|
47908
48105
|
const inflightMessages = /* @__PURE__ */ new Map();
|
|
47909
48106
|
const queue = /* @__PURE__ */ __name(async (queueName, message, opts) => {
|
|
47910
48107
|
const cleanup = [];
|
|
@@ -47936,46 +48133,56 @@ function createQueue(config3) {
|
|
|
47936
48133
|
});
|
|
47937
48134
|
}
|
|
47938
48135
|
(async () => {
|
|
47939
|
-
|
|
47940
|
-
|
|
47941
|
-
|
|
47942
|
-
|
|
47943
|
-
|
|
47944
|
-
|
|
47945
|
-
|
|
47946
|
-
|
|
47947
|
-
|
|
47948
|
-
|
|
47949
|
-
|
|
47950
|
-
"
|
|
47951
|
-
"
|
|
47952
|
-
|
|
47953
|
-
|
|
47954
|
-
|
|
47955
|
-
|
|
47956
|
-
|
|
47957
|
-
|
|
47958
|
-
|
|
47959
|
-
|
|
47960
|
-
|
|
47961
|
-
|
|
47962
|
-
|
|
47963
|
-
|
|
47964
|
-
defaultRetriesLeft++;
|
|
47965
|
-
continue;
|
|
48136
|
+
const token = semaphore.tryAcquire();
|
|
48137
|
+
if (!token) {
|
|
48138
|
+
console.warn(`[world-local]: concurrency limit (${WORKFLOW_LOCAL_QUEUE_CONCURRENCY}) reached, waiting for queue to free up`);
|
|
48139
|
+
await semaphore.acquire();
|
|
48140
|
+
}
|
|
48141
|
+
try {
|
|
48142
|
+
let defaultRetriesLeft = 3;
|
|
48143
|
+
const baseUrl = await resolveBaseUrl(config3);
|
|
48144
|
+
for (let attempt = 0; defaultRetriesLeft > 0; attempt++) {
|
|
48145
|
+
defaultRetriesLeft--;
|
|
48146
|
+
const response = await fetch(`${baseUrl}/.well-known/workflow/v1/${pathname}`, {
|
|
48147
|
+
method: "POST",
|
|
48148
|
+
duplex: "half",
|
|
48149
|
+
// @ts-expect-error undici type differences
|
|
48150
|
+
dispatcher: httpAgent,
|
|
48151
|
+
headers: {
|
|
48152
|
+
"content-type": "application/json",
|
|
48153
|
+
"x-vqs-queue-name": queueName,
|
|
48154
|
+
"x-vqs-message-id": messageId,
|
|
48155
|
+
"x-vqs-message-attempt": String(attempt + 1)
|
|
48156
|
+
},
|
|
48157
|
+
body
|
|
48158
|
+
});
|
|
48159
|
+
if (response.ok) {
|
|
48160
|
+
return;
|
|
47966
48161
|
}
|
|
47967
|
-
|
|
48162
|
+
const text = await response.text();
|
|
48163
|
+
if (response.status === 503) {
|
|
48164
|
+
try {
|
|
48165
|
+
const timeoutSeconds = Number(JSON.parse(text).timeoutSeconds);
|
|
48166
|
+
await (0, import_promises12.setTimeout)(timeoutSeconds * 1e3);
|
|
48167
|
+
defaultRetriesLeft++;
|
|
48168
|
+
continue;
|
|
48169
|
+
}
|
|
48170
|
+
catch {
|
|
48171
|
+
}
|
|
47968
48172
|
}
|
|
48173
|
+
console.error(`[embedded world] Failed to queue message`, {
|
|
48174
|
+
queueName,
|
|
48175
|
+
text,
|
|
48176
|
+
status: response.status,
|
|
48177
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
48178
|
+
body: body.toString()
|
|
48179
|
+
});
|
|
47969
48180
|
}
|
|
47970
|
-
console.error(`[embedded world]
|
|
47971
|
-
|
|
47972
|
-
|
|
47973
|
-
|
|
47974
|
-
headers: Object.fromEntries(response.headers.entries()),
|
|
47975
|
-
body: body.toString()
|
|
47976
|
-
});
|
|
48181
|
+
console.error(`[embedded world] Reached max retries of embedded world queue implementation`);
|
|
48182
|
+
}
|
|
48183
|
+
finally {
|
|
48184
|
+
semaphore.release();
|
|
47977
48185
|
}
|
|
47978
|
-
console.error(`[embedded world] Reached max retries of embedded world queue implementation`);
|
|
47979
48186
|
})().catch((err) => {
|
|
47980
48187
|
const isAbortError2 = err?.name === "AbortError" || err?.name === "ResponseAborted";
|
|
47981
48188
|
if (!isAbortError2) {
|
|
@@ -48864,7 +49071,7 @@ __name(createEmbeddedWorld, "createEmbeddedWorld");
|
|
|
48864
49071
|
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
48865
49072
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
48866
49073
|
// ../world-vercel/dist/version.js
|
|
48867
|
-
var version2 = "4.0.1-beta.
|
|
49074
|
+
var version2 = "4.0.1-beta.13";
|
|
48868
49075
|
// ../world-vercel/dist/utils.js
|
|
48869
49076
|
var DEFAULT_RESOLVE_DATA_OPTION2 = "all";
|
|
48870
49077
|
function dateToStringReplacer(_key, value) {
|
|
@@ -49022,7 +49229,7 @@ function createQueue2(config3) {
|
|
|
49022
49229
|
const queue = /* @__PURE__ */ __name(async (queueName, x, opts) => {
|
|
49023
49230
|
const hasEncoder = typeof MessageWrapper.encode === "function";
|
|
49024
49231
|
if (!hasEncoder) {
|
|
49025
|
-
|
|
49232
|
+
console.warn("Using zod v3 compatibility mode for queue() calls - this may not work as expected");
|
|
49026
49233
|
}
|
|
49027
49234
|
const encoder = hasEncoder ? MessageWrapper.encode : (data) => data;
|
|
49028
49235
|
const encoded = encoder({
|
|
@@ -49897,7 +50104,19 @@ function getCommonReducers(global3 = globalThis) {
|
|
|
49897
50104
|
if (typeof value !== "function")
|
|
49898
50105
|
return false;
|
|
49899
50106
|
const stepId = value.stepId;
|
|
49900
|
-
|
|
50107
|
+
if (typeof stepId !== "string")
|
|
50108
|
+
return false;
|
|
50109
|
+
const closureVarsFn = value.__closureVarsFn;
|
|
50110
|
+
if (closureVarsFn && typeof closureVarsFn === "function") {
|
|
50111
|
+
const closureVars = closureVarsFn();
|
|
50112
|
+
return {
|
|
50113
|
+
stepId,
|
|
50114
|
+
closureVars
|
|
50115
|
+
};
|
|
50116
|
+
}
|
|
50117
|
+
return {
|
|
50118
|
+
stepId
|
|
50119
|
+
};
|
|
49901
50120
|
}, "StepFunction"),
|
|
49902
50121
|
URL: /* @__PURE__ */ __name((value) => value instanceof global3.URL && value.href, "URL"),
|
|
49903
50122
|
URLSearchParams: /* @__PURE__ */ __name((value) => {
|
|
@@ -50017,9 +50236,37 @@ function getCommonRevivers(global3 = globalThis) {
|
|
|
50017
50236
|
RegExp: /* @__PURE__ */ __name((value) => new global3.RegExp(value.source, value.flags), "RegExp"),
|
|
50018
50237
|
Set: /* @__PURE__ */ __name((value) => new global3.Set(value), "Set"),
|
|
50019
50238
|
StepFunction: /* @__PURE__ */ __name((value) => {
|
|
50020
|
-
const
|
|
50239
|
+
const stepId = value.stepId;
|
|
50240
|
+
const closureVars = value.closureVars;
|
|
50241
|
+
const stepFn = getStepFunction(stepId);
|
|
50021
50242
|
if (!stepFn) {
|
|
50022
|
-
throw new Error(`Step function "${
|
|
50243
|
+
throw new Error(`Step function "${stepId}" not found. Make sure the step function is registered.`);
|
|
50244
|
+
}
|
|
50245
|
+
if (closureVars) {
|
|
50246
|
+
const wrappedStepFn = /* @__PURE__ */ __name((...args) => {
|
|
50247
|
+
const currentContext = contextStorage.getStore();
|
|
50248
|
+
if (!currentContext) {
|
|
50249
|
+
throw new Error("Cannot call step function with closure variables outside step context");
|
|
50250
|
+
}
|
|
50251
|
+
const newContext = {
|
|
50252
|
+
...currentContext,
|
|
50253
|
+
closureVars
|
|
50254
|
+
};
|
|
50255
|
+
return contextStorage.run(newContext, () => stepFn(...args));
|
|
50256
|
+
}, "wrappedStepFn");
|
|
50257
|
+
Object.defineProperty(wrappedStepFn, "name", {
|
|
50258
|
+
value: stepFn.name
|
|
50259
|
+
});
|
|
50260
|
+
Object.defineProperty(wrappedStepFn, "stepId", {
|
|
50261
|
+
value: stepId,
|
|
50262
|
+
writable: false,
|
|
50263
|
+
enumerable: false,
|
|
50264
|
+
configurable: false
|
|
50265
|
+
});
|
|
50266
|
+
if (stepFn.maxRetries !== void 0) {
|
|
50267
|
+
wrappedStepFn.maxRetries = stepFn.maxRetries;
|
|
50268
|
+
}
|
|
50269
|
+
return wrappedStepFn;
|
|
50023
50270
|
}
|
|
50024
50271
|
return stepFn;
|
|
50025
50272
|
}, "StepFunction"),
|
|
@@ -50358,9 +50605,6 @@ function defineHook({ schema } = {}) {
|
|
|
50358
50605
|
};
|
|
50359
50606
|
}
|
|
50360
50607
|
__name(defineHook, "defineHook");
|
|
50361
|
-
// ../core/dist/step/context-storage.js
|
|
50362
|
-
var import_node_async_hooks = require("node:async_hooks");
|
|
50363
|
-
var contextStorage = /* @__PURE__ */ new import_node_async_hooks.AsyncLocalStorage();
|
|
50364
50608
|
// ../core/dist/step/get-step-metadata.js
|
|
50365
50609
|
function getStepMetadata() {
|
|
50366
50610
|
const ctx = contextStorage.getStore();
|
|
@@ -50401,6 +50645,12 @@ async function add(num, num2) {
|
|
|
50401
50645
|
}
|
|
50402
50646
|
__name(add, "add");
|
|
50403
50647
|
registerStepFunction("step//workflows/addition.ts//add", add);
|
|
50648
|
+
// workflows/null-byte.ts
|
|
50649
|
+
async function nullByteStep() {
|
|
50650
|
+
return "null byte \0";
|
|
50651
|
+
}
|
|
50652
|
+
__name(nullByteStep, "nullByteStep");
|
|
50653
|
+
registerStepFunction("step//workflows/null-byte.ts//nullByteStep", nullByteStep);
|
|
50404
50654
|
// workflows/retriable-and-fatal.ts
|
|
50405
50655
|
async function stepThatThrowsRetryableError() {
|
|
50406
50656
|
const { attempt, stepStartedAt } = getStepMetadata();
|
|
@@ -50423,14 +50673,6 @@ async function stepThatFails() {
|
|
|
50423
50673
|
__name(stepThatFails, "stepThatFails");
|
|
50424
50674
|
registerStepFunction("step//workflows/retriable-and-fatal.ts//stepThatThrowsRetryableError", stepThatThrowsRetryableError);
|
|
50425
50675
|
registerStepFunction("step//workflows/retriable-and-fatal.ts//stepThatFails", stepThatFails);
|
|
50426
|
-
// workflows/noop.ts
|
|
50427
|
-
var count2 = 0;
|
|
50428
|
-
async function noop3(_i) {
|
|
50429
|
-
count2++;
|
|
50430
|
-
return count2;
|
|
50431
|
-
}
|
|
50432
|
-
__name(noop3, "noop");
|
|
50433
|
-
registerStepFunction("step//workflows/noop.ts//noop", noop3);
|
|
50434
50676
|
// ../core/dist/runtime.js
|
|
50435
50677
|
var import_functions4 = __toESM(require_functions(), 1);
|
|
50436
50678
|
// ../core/dist/logger.js
|
|
@@ -50596,7 +50838,8 @@ var stepEntrypoint = /* @__PURE__ */ getWorldHandlers().createQueueHandler("__wk
|
|
|
50596
50838
|
throw new WorkflowRuntimeError(`Step "${stepId}" has no "startedAt" timestamp`);
|
|
50597
50839
|
}
|
|
50598
50840
|
const ops = [];
|
|
50599
|
-
const
|
|
50841
|
+
const hydratedInput = hydrateStepArguments(step.input, ops, workflowRunId);
|
|
50842
|
+
const args = hydratedInput.args;
|
|
50600
50843
|
span?.setAttributes({
|
|
50601
50844
|
...StepArgumentsCount(args.length)
|
|
50602
50845
|
});
|
|
@@ -50613,8 +50856,9 @@ var stepEntrypoint = /* @__PURE__ */ getWorldHandlers().createQueueHandler("__wk
|
|
|
50613
50856
|
// solution only works for vercel + local worlds.
|
|
50614
50857
|
url: process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : `http://localhost:${port ?? 3e3}`
|
|
50615
50858
|
},
|
|
50616
|
-
ops
|
|
50617
|
-
|
|
50859
|
+
ops,
|
|
50860
|
+
closureVars: hydratedInput.closureVars
|
|
50861
|
+
}, () => stepFn.apply(null, args));
|
|
50618
50862
|
result = dehydrateStepReturnValue(result, ops, workflowRunId);
|
|
50619
50863
|
(0, import_functions4.waitUntil)(Promise.all(ops).catch((err) => {
|
|
50620
50864
|
const isAbortError2 = err?.name === "AbortError" || err?.name === "ResponseAborted";
|