@workflow/web 4.1.14 → 4.1.16
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/build/server/assets/{app-B2hObQJu.js → app-GbUkc_Xp.js} +5 -1
- package/build/server/assets/{highlighted-body-B3W2YXNL-c3Vtq09H.js → highlighted-body-B3W2YXNL-A5X3ZwtB.js} +6 -2
- package/build/server/assets/{index-B8YoYr9f.js → index-CMfOrLiJ.js} +4 -0
- package/build/server/assets/{index-ulh-Ko1q.js → index-DUMo8iW2.js} +7 -3
- package/build/server/assets/{index-meg9qk8y.js → index-hBO56emR.js} +4 -0
- package/build/server/assets/{mermaid-3ZIDBTTL-D9FphmOZ.js → mermaid-3ZIDBTTL-CJ4kkLUP.js} +6 -2
- package/build/server/assets/{server-build-CAufQfpc.js → server-build-BXSdchZI.js} +849 -453
- package/build/server/assets/{token-COKbCOS0.js → token-BdngUnpg.js} +6 -2
- package/build/server/assets/{token-util-TwMjSZSF.js → token-util-BVCPBo_Y.js} +6 -2
- package/build/server/index.js +5 -1
- package/package.json +6 -6
|
@@ -14,7 +14,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
14
14
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
15
15
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
16
16
|
var _a2, _b, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn, _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn, _reader;
|
|
17
|
-
import {
|
|
17
|
+
import { createRequire as __wkfCreateRequire } from "node:module";
|
|
18
|
+
if (typeof globalThis.require === "undefined") {
|
|
19
|
+
globalThis.require = __wkfCreateRequire(import.meta.url);
|
|
20
|
+
}
|
|
21
|
+
import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-GbUkc_Xp.js";
|
|
18
22
|
import require$$0$5, { PassThrough } from "node:stream";
|
|
19
23
|
import require$$0 from "util";
|
|
20
24
|
import require$$1 from "crypto";
|
|
@@ -81828,7 +81832,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
|
|
|
81828
81832
|
var et = ({ className: e, language: t, style: o, isIncomplete: n, ...s2 }) => jsxRuntimeExports.jsx("div", { className: f("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e), "data-incomplete": n || void 0, "data-language": t, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...o }, ...s2 });
|
|
81829
81833
|
var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
|
|
81830
81834
|
var ot = ({ language: e }) => jsxRuntimeExports.jsx("div", { className: "flex h-8 items-center text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: jsxRuntimeExports.jsx("span", { className: "ml-1 font-mono lowercase", children: e }) });
|
|
81831
|
-
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-
|
|
81835
|
+
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-A5X3ZwtB.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
|
|
81832
81836
|
let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
|
|
81833
81837
|
`).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
|
|
81834
81838
|
return jsxRuntimeExports.jsx(Se.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(et, { isIncomplete: s2, language: t, children: [jsxRuntimeExports.jsx(ot, { language: t }), n ? jsxRuntimeExports.jsx("div", { className: "pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end", children: jsxRuntimeExports.jsx("div", { className: "pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur", "data-streamdown": "code-block-actions", children: n }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(Qe, { className: o, language: t, result: c, ...r2 }), children: jsxRuntimeExports.jsx(dn, { className: o, code: i, language: t, raw: c, ...r2 }) })] }) });
|
|
@@ -82150,7 +82154,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
|
|
|
82150
82154
|
}, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
|
|
82151
82155
|
};
|
|
82152
82156
|
var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
|
|
82153
|
-
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-
|
|
82157
|
+
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CJ4kkLUP.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
|
|
82154
82158
|
function ke(e, t) {
|
|
82155
82159
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
82156
82160
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
|
@@ -90910,6 +90914,15 @@ class ThrottleError extends WorkflowWorldError {
|
|
|
90910
90914
|
return isError(value) && value.name === "ThrottleError";
|
|
90911
90915
|
}
|
|
90912
90916
|
}
|
|
90917
|
+
class PreconditionFailedError extends WorkflowWorldError {
|
|
90918
|
+
constructor(message2, options) {
|
|
90919
|
+
super(message2, { status: 412, retryAfter: options == null ? void 0 : options.retryAfter });
|
|
90920
|
+
this.name = "PreconditionFailedError";
|
|
90921
|
+
}
|
|
90922
|
+
static is(value) {
|
|
90923
|
+
return isError(value) && value.name === "PreconditionFailedError";
|
|
90924
|
+
}
|
|
90925
|
+
}
|
|
90913
90926
|
class WorkflowRunCancelledError extends WorkflowError {
|
|
90914
90927
|
constructor(runId) {
|
|
90915
90928
|
super(`Workflow run "${runId}" cancelled`, {});
|
|
@@ -91888,7 +91901,7 @@ async function withTraceContext(traceCarrier, fn2) {
|
|
|
91888
91901
|
}
|
|
91889
91902
|
const OtelApi = once$1(async () => {
|
|
91890
91903
|
try {
|
|
91891
|
-
return await import("./index-
|
|
91904
|
+
return await import("./index-hBO56emR.js");
|
|
91892
91905
|
} catch {
|
|
91893
91906
|
runtimeLogger.info("OpenTelemetry not available, tracing will be disabled");
|
|
91894
91907
|
return null;
|
|
@@ -92033,7 +92046,7 @@ createLogger("build", {
|
|
|
92033
92046
|
debugNamespace: "workflow:build"
|
|
92034
92047
|
});
|
|
92035
92048
|
const MAX_QUEUE_DELIVERIES = 48;
|
|
92036
|
-
const version$1 = "4.
|
|
92049
|
+
const version$1 = "4.8.0";
|
|
92037
92050
|
const execFileAsync = promisify(execFile);
|
|
92038
92051
|
function parsePort$1(value, radix = 10) {
|
|
92039
92052
|
const port = parseInt(value, radix);
|
|
@@ -92488,7 +92501,7 @@ async function readFirstByte(filePath) {
|
|
|
92488
92501
|
}
|
|
92489
92502
|
async function deleteJSON(filePath) {
|
|
92490
92503
|
try {
|
|
92491
|
-
await promises.unlink(filePath);
|
|
92504
|
+
await withWindowsRetry(() => promises.unlink(filePath));
|
|
92492
92505
|
} catch (error2) {
|
|
92493
92506
|
if (error2.code !== "ENOENT")
|
|
92494
92507
|
throw error2;
|
|
@@ -92793,7 +92806,7 @@ async function initDataDir(dataDir) {
|
|
|
92793
92806
|
let otelApiPromise$1 = null;
|
|
92794
92807
|
async function getOtelApi$1() {
|
|
92795
92808
|
if (!otelApiPromise$1) {
|
|
92796
|
-
otelApiPromise$1 = import("./index-
|
|
92809
|
+
otelApiPromise$1 = import("./index-hBO56emR.js").catch(() => null);
|
|
92797
92810
|
}
|
|
92798
92811
|
return otelApiPromise$1;
|
|
92799
92812
|
}
|
|
@@ -100033,8 +100046,8 @@ function requireClientH1() {
|
|
|
100033
100046
|
return this.createError(ret, EMPTY_BUF);
|
|
100034
100047
|
}
|
|
100035
100048
|
createError(ret, data) {
|
|
100036
|
-
const { llhttp, contentLength, bytesRead } = this;
|
|
100037
|
-
if (
|
|
100049
|
+
const { llhttp, contentLength: contentLength2, bytesRead } = this;
|
|
100050
|
+
if (contentLength2 && bytesRead !== parseInt(contentLength2, 10)) {
|
|
100038
100051
|
return new ResponseContentLengthMismatchError();
|
|
100039
100052
|
}
|
|
100040
100053
|
const ptr = llhttp.llhttp_get_error_reason(this.ptr);
|
|
@@ -100287,7 +100300,7 @@ function requireClientH1() {
|
|
|
100287
100300
|
* @returns {number}
|
|
100288
100301
|
*/
|
|
100289
100302
|
onMessageComplete() {
|
|
100290
|
-
const { client: client2, socket, statusCode, upgrade, headers: headers2, contentLength, bytesRead, shouldKeepAlive } = this;
|
|
100303
|
+
const { client: client2, socket, statusCode, upgrade, headers: headers2, contentLength: contentLength2, bytesRead, shouldKeepAlive } = this;
|
|
100291
100304
|
if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
|
|
100292
100305
|
return -1;
|
|
100293
100306
|
}
|
|
@@ -100309,7 +100322,7 @@ function requireClientH1() {
|
|
|
100309
100322
|
if (statusCode < 200) {
|
|
100310
100323
|
return 0;
|
|
100311
100324
|
}
|
|
100312
|
-
if (request2.method !== "HEAD" &&
|
|
100325
|
+
if (request2.method !== "HEAD" && contentLength2 && bytesRead !== parseInt(contentLength2, 10)) {
|
|
100313
100326
|
util2.destroy(socket, new ResponseContentLengthMismatchError());
|
|
100314
100327
|
return -1;
|
|
100315
100328
|
}
|
|
@@ -100564,7 +100577,7 @@ function requireClientH1() {
|
|
|
100564
100577
|
}
|
|
100565
100578
|
function writeH1(client2, request2) {
|
|
100566
100579
|
const { method, path: path2, host, upgrade, blocking, reset } = request2;
|
|
100567
|
-
let { body: body2, headers: headers2, contentLength } = request2;
|
|
100580
|
+
let { body: body2, headers: headers2, contentLength: contentLength2 } = request2;
|
|
100568
100581
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
100569
100582
|
if (util2.isFormDataLike(body2)) {
|
|
100570
100583
|
if (!extractBody) {
|
|
@@ -100575,7 +100588,7 @@ function requireClientH1() {
|
|
|
100575
100588
|
headers2.push("content-type", contentType);
|
|
100576
100589
|
}
|
|
100577
100590
|
body2 = bodyStream.stream;
|
|
100578
|
-
|
|
100591
|
+
contentLength2 = bodyStream.length;
|
|
100579
100592
|
} else if (util2.isBlobLike(body2) && request2.contentType == null && body2.type) {
|
|
100580
100593
|
headers2.push("content-type", body2.type);
|
|
100581
100594
|
}
|
|
@@ -100583,14 +100596,14 @@ function requireClientH1() {
|
|
|
100583
100596
|
body2.read(0);
|
|
100584
100597
|
}
|
|
100585
100598
|
const bodyLength = util2.bodyLength(body2);
|
|
100586
|
-
|
|
100587
|
-
if (
|
|
100588
|
-
|
|
100599
|
+
contentLength2 = bodyLength ?? contentLength2;
|
|
100600
|
+
if (contentLength2 === null) {
|
|
100601
|
+
contentLength2 = request2.contentLength;
|
|
100589
100602
|
}
|
|
100590
|
-
if (
|
|
100591
|
-
|
|
100603
|
+
if (contentLength2 === 0 && !expectsPayload) {
|
|
100604
|
+
contentLength2 = null;
|
|
100592
100605
|
}
|
|
100593
|
-
if (shouldSendContentLength(method) &&
|
|
100606
|
+
if (shouldSendContentLength(method) && contentLength2 > 0 && request2.contentLength !== null && request2.contentLength !== contentLength2) {
|
|
100594
100607
|
if (client2[kStrictContentLength]) {
|
|
100595
100608
|
util2.errorRequest(client2, request2, new RequestContentLengthMismatchError());
|
|
100596
100609
|
return false;
|
|
@@ -100669,28 +100682,28 @@ upgrade: ${upgrade}\r
|
|
|
100669
100682
|
channels.sendHeaders.publish({ request: request2, headers: header, socket });
|
|
100670
100683
|
}
|
|
100671
100684
|
if (!body2 || bodyLength === 0) {
|
|
100672
|
-
writeBuffer2(abort, null, client2, request2, socket,
|
|
100685
|
+
writeBuffer2(abort, null, client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100673
100686
|
} else if (util2.isBuffer(body2)) {
|
|
100674
|
-
writeBuffer2(abort, body2, client2, request2, socket,
|
|
100687
|
+
writeBuffer2(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100675
100688
|
} else if (util2.isBlobLike(body2)) {
|
|
100676
100689
|
if (typeof body2.stream === "function") {
|
|
100677
|
-
writeIterable(abort, body2.stream(), client2, request2, socket,
|
|
100690
|
+
writeIterable(abort, body2.stream(), client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100678
100691
|
} else {
|
|
100679
|
-
writeBlob(abort, body2, client2, request2, socket,
|
|
100692
|
+
writeBlob(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100680
100693
|
}
|
|
100681
100694
|
} else if (util2.isStream(body2)) {
|
|
100682
|
-
writeStream(abort, body2, client2, request2, socket,
|
|
100695
|
+
writeStream(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100683
100696
|
} else if (util2.isIterable(body2)) {
|
|
100684
|
-
writeIterable(abort, body2, client2, request2, socket,
|
|
100697
|
+
writeIterable(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
|
|
100685
100698
|
} else {
|
|
100686
100699
|
assert2(false);
|
|
100687
100700
|
}
|
|
100688
100701
|
return true;
|
|
100689
100702
|
}
|
|
100690
|
-
function writeStream(abort, body2, client2, request2, socket,
|
|
100691
|
-
assert2(
|
|
100703
|
+
function writeStream(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
|
|
100704
|
+
assert2(contentLength2 !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
|
|
100692
100705
|
let finished = false;
|
|
100693
|
-
const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header });
|
|
100706
|
+
const writer = new AsyncWriter({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header });
|
|
100694
100707
|
const onData = function(chunk) {
|
|
100695
100708
|
if (finished) {
|
|
100696
100709
|
return;
|
|
@@ -100756,22 +100769,22 @@ upgrade: ${upgrade}\r
|
|
|
100756
100769
|
setImmediate(onClose);
|
|
100757
100770
|
}
|
|
100758
100771
|
}
|
|
100759
|
-
function writeBuffer2(abort, body2, client2, request2, socket,
|
|
100772
|
+
function writeBuffer2(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
|
|
100760
100773
|
try {
|
|
100761
100774
|
if (!body2) {
|
|
100762
|
-
if (
|
|
100775
|
+
if (contentLength2 === 0) {
|
|
100763
100776
|
socket.write(`${header}content-length: 0\r
|
|
100764
100777
|
\r
|
|
100765
100778
|
`, "latin1");
|
|
100766
100779
|
} else {
|
|
100767
|
-
assert2(
|
|
100780
|
+
assert2(contentLength2 === null, "no body must not have content length");
|
|
100768
100781
|
socket.write(`${header}\r
|
|
100769
100782
|
`, "latin1");
|
|
100770
100783
|
}
|
|
100771
100784
|
} else if (util2.isBuffer(body2)) {
|
|
100772
|
-
assert2(
|
|
100785
|
+
assert2(contentLength2 === body2.byteLength, "buffer body must have content length");
|
|
100773
100786
|
socket.cork();
|
|
100774
|
-
socket.write(`${header}content-length: ${
|
|
100787
|
+
socket.write(`${header}content-length: ${contentLength2}\r
|
|
100775
100788
|
\r
|
|
100776
100789
|
`, "latin1");
|
|
100777
100790
|
socket.write(body2);
|
|
@@ -100787,15 +100800,15 @@ upgrade: ${upgrade}\r
|
|
|
100787
100800
|
abort(err);
|
|
100788
100801
|
}
|
|
100789
100802
|
}
|
|
100790
|
-
async function writeBlob(abort, body2, client2, request2, socket,
|
|
100791
|
-
assert2(
|
|
100803
|
+
async function writeBlob(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
|
|
100804
|
+
assert2(contentLength2 === body2.size, "blob body must have content length");
|
|
100792
100805
|
try {
|
|
100793
|
-
if (
|
|
100806
|
+
if (contentLength2 != null && contentLength2 !== body2.size) {
|
|
100794
100807
|
throw new RequestContentLengthMismatchError();
|
|
100795
100808
|
}
|
|
100796
100809
|
const buffer2 = Buffer.from(await body2.arrayBuffer());
|
|
100797
100810
|
socket.cork();
|
|
100798
|
-
socket.write(`${header}content-length: ${
|
|
100811
|
+
socket.write(`${header}content-length: ${contentLength2}\r
|
|
100799
100812
|
\r
|
|
100800
100813
|
`, "latin1");
|
|
100801
100814
|
socket.write(buffer2);
|
|
@@ -100810,8 +100823,8 @@ upgrade: ${upgrade}\r
|
|
|
100810
100823
|
abort(err);
|
|
100811
100824
|
}
|
|
100812
100825
|
}
|
|
100813
|
-
async function writeIterable(abort, body2, client2, request2, socket,
|
|
100814
|
-
assert2(
|
|
100826
|
+
async function writeIterable(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
|
|
100827
|
+
assert2(contentLength2 !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
|
|
100815
100828
|
let callback = null;
|
|
100816
100829
|
function onDrain() {
|
|
100817
100830
|
if (callback) {
|
|
@@ -100829,7 +100842,7 @@ upgrade: ${upgrade}\r
|
|
|
100829
100842
|
}
|
|
100830
100843
|
});
|
|
100831
100844
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
100832
|
-
const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header });
|
|
100845
|
+
const writer = new AsyncWriter({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header });
|
|
100833
100846
|
try {
|
|
100834
100847
|
for await (const chunk of body2) {
|
|
100835
100848
|
if (socket[kError]) {
|
|
@@ -100858,10 +100871,10 @@ upgrade: ${upgrade}\r
|
|
|
100858
100871
|
* @param {boolean} arg.expectsPayload
|
|
100859
100872
|
* @param {string} arg.header
|
|
100860
100873
|
*/
|
|
100861
|
-
constructor({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header }) {
|
|
100874
|
+
constructor({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header }) {
|
|
100862
100875
|
this.socket = socket;
|
|
100863
100876
|
this.request = request2;
|
|
100864
|
-
this.contentLength =
|
|
100877
|
+
this.contentLength = contentLength2;
|
|
100865
100878
|
this.client = client2;
|
|
100866
100879
|
this.bytesWritten = 0;
|
|
100867
100880
|
this.expectsPayload = expectsPayload;
|
|
@@ -100874,7 +100887,7 @@ upgrade: ${upgrade}\r
|
|
|
100874
100887
|
* @returns
|
|
100875
100888
|
*/
|
|
100876
100889
|
write(chunk) {
|
|
100877
|
-
const { socket, request: request2, contentLength, client: client2, bytesWritten, expectsPayload, header } = this;
|
|
100890
|
+
const { socket, request: request2, contentLength: contentLength2, client: client2, bytesWritten, expectsPayload, header } = this;
|
|
100878
100891
|
if (socket[kError]) {
|
|
100879
100892
|
throw socket[kError];
|
|
100880
100893
|
}
|
|
@@ -100885,7 +100898,7 @@ upgrade: ${upgrade}\r
|
|
|
100885
100898
|
if (!len) {
|
|
100886
100899
|
return true;
|
|
100887
100900
|
}
|
|
100888
|
-
if (
|
|
100901
|
+
if (contentLength2 !== null && bytesWritten + len > contentLength2) {
|
|
100889
100902
|
if (client2[kStrictContentLength]) {
|
|
100890
100903
|
throw new RequestContentLengthMismatchError();
|
|
100891
100904
|
}
|
|
@@ -100896,16 +100909,16 @@ upgrade: ${upgrade}\r
|
|
|
100896
100909
|
if (!expectsPayload && request2.reset !== false) {
|
|
100897
100910
|
socket[kReset] = true;
|
|
100898
100911
|
}
|
|
100899
|
-
if (
|
|
100912
|
+
if (contentLength2 === null) {
|
|
100900
100913
|
socket.write(`${header}transfer-encoding: chunked\r
|
|
100901
100914
|
`, "latin1");
|
|
100902
100915
|
} else {
|
|
100903
|
-
socket.write(`${header}content-length: ${
|
|
100916
|
+
socket.write(`${header}content-length: ${contentLength2}\r
|
|
100904
100917
|
\r
|
|
100905
100918
|
`, "latin1");
|
|
100906
100919
|
}
|
|
100907
100920
|
}
|
|
100908
|
-
if (
|
|
100921
|
+
if (contentLength2 === null) {
|
|
100909
100922
|
socket.write(`\r
|
|
100910
100923
|
${len.toString(16)}\r
|
|
100911
100924
|
`, "latin1");
|
|
@@ -100927,7 +100940,7 @@ ${len.toString(16)}\r
|
|
|
100927
100940
|
* @returns {void}
|
|
100928
100941
|
*/
|
|
100929
100942
|
end() {
|
|
100930
|
-
const { socket, contentLength, client: client2, bytesWritten, expectsPayload, header, request: request2 } = this;
|
|
100943
|
+
const { socket, contentLength: contentLength2, client: client2, bytesWritten, expectsPayload, header, request: request2 } = this;
|
|
100931
100944
|
request2.onRequestSent();
|
|
100932
100945
|
socket[kWriting] = false;
|
|
100933
100946
|
if (socket[kError]) {
|
|
@@ -100945,10 +100958,10 @@ ${len.toString(16)}\r
|
|
|
100945
100958
|
socket.write(`${header}\r
|
|
100946
100959
|
`, "latin1");
|
|
100947
100960
|
}
|
|
100948
|
-
} else if (
|
|
100961
|
+
} else if (contentLength2 === null) {
|
|
100949
100962
|
socket.write("\r\n0\r\n\r\n", "latin1");
|
|
100950
100963
|
}
|
|
100951
|
-
if (
|
|
100964
|
+
if (contentLength2 !== null && bytesWritten !== contentLength2) {
|
|
100952
100965
|
if (client2[kStrictContentLength]) {
|
|
100953
100966
|
throw new RequestContentLengthMismatchError();
|
|
100954
100967
|
} else {
|
|
@@ -101401,30 +101414,30 @@ function requireClientH2() {
|
|
|
101401
101414
|
if (body2 && typeof body2.read === "function") {
|
|
101402
101415
|
body2.read(0);
|
|
101403
101416
|
}
|
|
101404
|
-
let
|
|
101417
|
+
let contentLength2 = util2.bodyLength(body2);
|
|
101405
101418
|
if (util2.isFormDataLike(body2)) {
|
|
101406
101419
|
extractBody ?? (extractBody = requireBody().extractBody);
|
|
101407
101420
|
const [bodyStream, contentType] = extractBody(body2);
|
|
101408
101421
|
headers2["content-type"] = contentType;
|
|
101409
101422
|
body2 = bodyStream.stream;
|
|
101410
|
-
|
|
101423
|
+
contentLength2 = bodyStream.length;
|
|
101411
101424
|
}
|
|
101412
|
-
if (
|
|
101413
|
-
|
|
101425
|
+
if (contentLength2 == null) {
|
|
101426
|
+
contentLength2 = request2.contentLength;
|
|
101414
101427
|
}
|
|
101415
101428
|
if (!expectsPayload) {
|
|
101416
|
-
|
|
101429
|
+
contentLength2 = null;
|
|
101417
101430
|
}
|
|
101418
|
-
if (shouldSendContentLength(method) &&
|
|
101431
|
+
if (shouldSendContentLength(method) && contentLength2 > 0 && request2.contentLength != null && request2.contentLength !== contentLength2) {
|
|
101419
101432
|
if (client2[kStrictContentLength]) {
|
|
101420
101433
|
util2.errorRequest(client2, request2, new RequestContentLengthMismatchError());
|
|
101421
101434
|
return false;
|
|
101422
101435
|
}
|
|
101423
101436
|
process.emitWarning(new RequestContentLengthMismatchError());
|
|
101424
101437
|
}
|
|
101425
|
-
if (
|
|
101426
|
-
assert2(body2 ||
|
|
101427
|
-
headers2[HTTP2_HEADER_CONTENT_LENGTH] = `${
|
|
101438
|
+
if (contentLength2 != null) {
|
|
101439
|
+
assert2(body2 || contentLength2 === 0, "no body must not have content length");
|
|
101440
|
+
headers2[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength2}`;
|
|
101428
101441
|
}
|
|
101429
101442
|
session.ref();
|
|
101430
101443
|
if (channels.sendHeaders.hasSubscribers) {
|
|
@@ -101523,7 +101536,7 @@ function requireClientH2() {
|
|
|
101523
101536
|
});
|
|
101524
101537
|
return true;
|
|
101525
101538
|
function writeBodyH2() {
|
|
101526
|
-
if (!body2 ||
|
|
101539
|
+
if (!body2 || contentLength2 === 0) {
|
|
101527
101540
|
writeBuffer2(
|
|
101528
101541
|
abort,
|
|
101529
101542
|
stream,
|
|
@@ -101531,7 +101544,7 @@ function requireClientH2() {
|
|
|
101531
101544
|
client2,
|
|
101532
101545
|
request2,
|
|
101533
101546
|
client2[kSocket],
|
|
101534
|
-
|
|
101547
|
+
contentLength2,
|
|
101535
101548
|
expectsPayload
|
|
101536
101549
|
);
|
|
101537
101550
|
} else if (util2.isBuffer(body2)) {
|
|
@@ -101542,7 +101555,7 @@ function requireClientH2() {
|
|
|
101542
101555
|
client2,
|
|
101543
101556
|
request2,
|
|
101544
101557
|
client2[kSocket],
|
|
101545
|
-
|
|
101558
|
+
contentLength2,
|
|
101546
101559
|
expectsPayload
|
|
101547
101560
|
);
|
|
101548
101561
|
} else if (util2.isBlobLike(body2)) {
|
|
@@ -101554,7 +101567,7 @@ function requireClientH2() {
|
|
|
101554
101567
|
client2,
|
|
101555
101568
|
request2,
|
|
101556
101569
|
client2[kSocket],
|
|
101557
|
-
|
|
101570
|
+
contentLength2,
|
|
101558
101571
|
expectsPayload
|
|
101559
101572
|
);
|
|
101560
101573
|
} else {
|
|
@@ -101565,7 +101578,7 @@ function requireClientH2() {
|
|
|
101565
101578
|
client2,
|
|
101566
101579
|
request2,
|
|
101567
101580
|
client2[kSocket],
|
|
101568
|
-
|
|
101581
|
+
contentLength2,
|
|
101569
101582
|
expectsPayload
|
|
101570
101583
|
);
|
|
101571
101584
|
}
|
|
@@ -101578,7 +101591,7 @@ function requireClientH2() {
|
|
|
101578
101591
|
body2,
|
|
101579
101592
|
client2,
|
|
101580
101593
|
request2,
|
|
101581
|
-
|
|
101594
|
+
contentLength2
|
|
101582
101595
|
);
|
|
101583
101596
|
} else if (util2.isIterable(body2)) {
|
|
101584
101597
|
writeIterable(
|
|
@@ -101588,7 +101601,7 @@ function requireClientH2() {
|
|
|
101588
101601
|
client2,
|
|
101589
101602
|
request2,
|
|
101590
101603
|
client2[kSocket],
|
|
101591
|
-
|
|
101604
|
+
contentLength2,
|
|
101592
101605
|
expectsPayload
|
|
101593
101606
|
);
|
|
101594
101607
|
} else {
|
|
@@ -101596,10 +101609,10 @@ function requireClientH2() {
|
|
|
101596
101609
|
}
|
|
101597
101610
|
}
|
|
101598
101611
|
}
|
|
101599
|
-
function writeBuffer2(abort, h2stream, body2, client2, request2, socket,
|
|
101612
|
+
function writeBuffer2(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
|
|
101600
101613
|
try {
|
|
101601
101614
|
if (body2 != null && util2.isBuffer(body2)) {
|
|
101602
|
-
assert2(
|
|
101615
|
+
assert2(contentLength2 === body2.byteLength, "buffer body must have content length");
|
|
101603
101616
|
h2stream.cork();
|
|
101604
101617
|
h2stream.write(body2);
|
|
101605
101618
|
h2stream.uncork();
|
|
@@ -101615,8 +101628,8 @@ function requireClientH2() {
|
|
|
101615
101628
|
abort(error2);
|
|
101616
101629
|
}
|
|
101617
101630
|
}
|
|
101618
|
-
function writeStream(abort, socket, expectsPayload, h2stream, body2, client2, request2,
|
|
101619
|
-
assert2(
|
|
101631
|
+
function writeStream(abort, socket, expectsPayload, h2stream, body2, client2, request2, contentLength2) {
|
|
101632
|
+
assert2(contentLength2 !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
|
|
101620
101633
|
const pipe2 = pipeline(
|
|
101621
101634
|
body2,
|
|
101622
101635
|
h2stream,
|
|
@@ -101639,10 +101652,10 @@ function requireClientH2() {
|
|
|
101639
101652
|
request2.onBodySent(chunk);
|
|
101640
101653
|
}
|
|
101641
101654
|
}
|
|
101642
|
-
async function writeBlob(abort, h2stream, body2, client2, request2, socket,
|
|
101643
|
-
assert2(
|
|
101655
|
+
async function writeBlob(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
|
|
101656
|
+
assert2(contentLength2 === body2.size, "blob body must have content length");
|
|
101644
101657
|
try {
|
|
101645
|
-
if (
|
|
101658
|
+
if (contentLength2 != null && contentLength2 !== body2.size) {
|
|
101646
101659
|
throw new RequestContentLengthMismatchError();
|
|
101647
101660
|
}
|
|
101648
101661
|
const buffer2 = Buffer.from(await body2.arrayBuffer());
|
|
@@ -101660,8 +101673,8 @@ function requireClientH2() {
|
|
|
101660
101673
|
abort(err);
|
|
101661
101674
|
}
|
|
101662
101675
|
}
|
|
101663
|
-
async function writeIterable(abort, h2stream, body2, client2, request2, socket,
|
|
101664
|
-
assert2(
|
|
101676
|
+
async function writeIterable(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
|
|
101677
|
+
assert2(contentLength2 !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
|
|
101665
101678
|
let callback = null;
|
|
101666
101679
|
function onDrain() {
|
|
101667
101680
|
if (callback) {
|
|
@@ -104301,8 +104314,8 @@ function requireRetryHandler() {
|
|
|
104301
104314
|
this.end = end;
|
|
104302
104315
|
}
|
|
104303
104316
|
if (this.end == null) {
|
|
104304
|
-
const
|
|
104305
|
-
this.end =
|
|
104317
|
+
const contentLength2 = headers2["content-length"];
|
|
104318
|
+
this.end = contentLength2 != null ? Number(contentLength2) - 1 : null;
|
|
104306
104319
|
}
|
|
104307
104320
|
assert2(Number.isFinite(this.start));
|
|
104308
104321
|
assert2(
|
|
@@ -104518,7 +104531,7 @@ function requireReadable() {
|
|
|
104518
104531
|
resume,
|
|
104519
104532
|
abort,
|
|
104520
104533
|
contentType = "",
|
|
104521
|
-
contentLength,
|
|
104534
|
+
contentLength: contentLength2,
|
|
104522
104535
|
highWaterMark = 64 * 1024
|
|
104523
104536
|
// Same as nodejs fs streams.
|
|
104524
104537
|
}) {
|
|
@@ -104534,7 +104547,7 @@ function requireReadable() {
|
|
|
104534
104547
|
this[kBody] = null;
|
|
104535
104548
|
this[kUsed] = false;
|
|
104536
104549
|
this[kContentType] = contentType;
|
|
104537
|
-
this[kContentLength] = Number.isFinite(
|
|
104550
|
+
this[kContentLength] = Number.isFinite(contentLength2) ? contentLength2 : null;
|
|
104538
104551
|
this[kReading] = false;
|
|
104539
104552
|
}
|
|
104540
104553
|
/**
|
|
@@ -104974,12 +104987,12 @@ function requireApiRequest() {
|
|
|
104974
104987
|
}
|
|
104975
104988
|
const parsedHeaders = responseHeaders === "raw" ? util2.parseHeaders(rawHeaders) : headers2;
|
|
104976
104989
|
const contentType = parsedHeaders["content-type"];
|
|
104977
|
-
const
|
|
104990
|
+
const contentLength2 = parsedHeaders["content-length"];
|
|
104978
104991
|
const res = new Readable({
|
|
104979
104992
|
resume,
|
|
104980
104993
|
abort,
|
|
104981
104994
|
contentType,
|
|
104982
|
-
contentLength: this.method !== "HEAD" &&
|
|
104995
|
+
contentLength: this.method !== "HEAD" && contentLength2 ? Number(contentLength2) : null,
|
|
104983
104996
|
highWaterMark
|
|
104984
104997
|
});
|
|
104985
104998
|
if (this.removeAbortListener) {
|
|
@@ -106199,8 +106212,8 @@ function requireMockInterceptor() {
|
|
|
106199
106212
|
}
|
|
106200
106213
|
createMockScopeDispatchData({ statusCode, data, responseOptions }) {
|
|
106201
106214
|
const responseData = getResponseData(data);
|
|
106202
|
-
const
|
|
106203
|
-
const headers2 = { ...this[kDefaultHeaders], ...
|
|
106215
|
+
const contentLength2 = this[kContentLength] ? { "content-length": responseData.length } : {};
|
|
106216
|
+
const headers2 = { ...this[kDefaultHeaders], ...contentLength2, ...responseOptions.headers };
|
|
106204
106217
|
const trailers = { ...this[kDefaultTrailers], ...responseOptions.trailers };
|
|
106205
106218
|
return { statusCode, data, headers: headers2, trailers };
|
|
106206
106219
|
}
|
|
@@ -108043,10 +108056,10 @@ function requireDump() {
|
|
|
108043
108056
|
return super.onRequestStart(controller, context);
|
|
108044
108057
|
}
|
|
108045
108058
|
onResponseStart(controller, statusCode, headers2, statusMessage) {
|
|
108046
|
-
const
|
|
108047
|
-
if (
|
|
108059
|
+
const contentLength2 = headers2["content-length"];
|
|
108060
|
+
if (contentLength2 != null && contentLength2 > __privateGet(this, _maxSize2)) {
|
|
108048
108061
|
throw new RequestAbortedError(
|
|
108049
|
-
`Response size (${
|
|
108062
|
+
`Response size (${contentLength2}) larger than maxSize (${__privateGet(this, _maxSize2)})`
|
|
108050
108063
|
);
|
|
108051
108064
|
}
|
|
108052
108065
|
if (this.aborted === true) {
|
|
@@ -113865,18 +113878,18 @@ function requireFetch() {
|
|
|
113865
113878
|
httpFetchParams.request = httpRequest;
|
|
113866
113879
|
}
|
|
113867
113880
|
const includeCredentials = request2.credentials === "include" || request2.credentials === "same-origin" && request2.responseTainting === "basic";
|
|
113868
|
-
const
|
|
113881
|
+
const contentLength2 = httpRequest.body ? httpRequest.body.length : null;
|
|
113869
113882
|
let contentLengthHeaderValue = null;
|
|
113870
113883
|
if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) {
|
|
113871
113884
|
contentLengthHeaderValue = "0";
|
|
113872
113885
|
}
|
|
113873
|
-
if (
|
|
113874
|
-
contentLengthHeaderValue = isomorphicEncode(`${
|
|
113886
|
+
if (contentLength2 != null) {
|
|
113887
|
+
contentLengthHeaderValue = isomorphicEncode(`${contentLength2}`);
|
|
113875
113888
|
}
|
|
113876
113889
|
if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) {
|
|
113877
113890
|
httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
|
|
113878
113891
|
}
|
|
113879
|
-
if (
|
|
113892
|
+
if (contentLength2 != null && httpRequest.keepalive) ;
|
|
113880
113893
|
if (webidl.is.URL(httpRequest.referrer)) {
|
|
113881
113894
|
httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
|
|
113882
113895
|
}
|
|
@@ -119008,6 +119021,12 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
|
|
|
119008
119021
|
throw new Error(`Event type '${data.eventType}' not supported for legacy runs (specVersion: ${currentRun.specVersion || "undefined"}). Please upgrade 'workflow' package.`);
|
|
119009
119022
|
}
|
|
119010
119023
|
}
|
|
119024
|
+
const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
|
|
119025
|
+
function getMaxEventsPerRun() {
|
|
119026
|
+
const raw2 = process.env.WORKFLOW_MAX_EVENTS;
|
|
119027
|
+
const parsed = raw2 !== void 0 ? Number(raw2) : Number.NaN;
|
|
119028
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_EVENTS_PER_RUN;
|
|
119029
|
+
}
|
|
119011
119030
|
const HookTokenClaimSchema = object$1({
|
|
119012
119031
|
// The token-claim writer below has always persisted `hookId`, but
|
|
119013
119032
|
// this read schema previously omitted it, which is the bug fixed
|
|
@@ -119239,7 +119258,8 @@ function createEventsStorage(basedir, tag) {
|
|
|
119239
119258
|
const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
119240
119259
|
return {
|
|
119241
119260
|
event: stripEventDataRefs(event2, resolveData2),
|
|
119242
|
-
run: currentRun
|
|
119261
|
+
run: currentRun,
|
|
119262
|
+
...currentRun ? { maxEvents: getMaxEventsPerRun() } : {}
|
|
119243
119263
|
};
|
|
119244
119264
|
}
|
|
119245
119265
|
if (data.eventType === "run_started") {
|
|
@@ -119322,7 +119342,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
119322
119342
|
} else if (data.eventType === "run_started") {
|
|
119323
119343
|
if (currentRun) {
|
|
119324
119344
|
if (currentRun.status === "running") {
|
|
119325
|
-
return { run: currentRun };
|
|
119345
|
+
return { run: currentRun, maxEvents: getMaxEventsPerRun() };
|
|
119326
119346
|
}
|
|
119327
119347
|
run2 = {
|
|
119328
119348
|
runId: currentRun.runId,
|
|
@@ -119705,7 +119725,9 @@ function createEventsStorage(basedir, tag) {
|
|
|
119705
119725
|
wait: wait2,
|
|
119706
119726
|
events: events2,
|
|
119707
119727
|
cursor,
|
|
119708
|
-
hasMore
|
|
119728
|
+
hasMore,
|
|
119729
|
+
// Per-run event ceiling (mirrors the Vercel World).
|
|
119730
|
+
...run2 ? { maxEvents: getMaxEventsPerRun() } : {}
|
|
119709
119731
|
};
|
|
119710
119732
|
}
|
|
119711
119733
|
},
|
|
@@ -120294,7 +120316,7 @@ function createLocalWorld(args) {
|
|
|
120294
120316
|
const basedir = mergedConfig.dataDir;
|
|
120295
120317
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
120296
120318
|
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
120297
|
-
const { HookSchema: HookSchema2 } = await import("./index-
|
|
120319
|
+
const { HookSchema: HookSchema2 } = await import("./index-DUMo8iW2.js");
|
|
120298
120320
|
await Promise.all(taggedHookFiles.map(async (hookFile) => {
|
|
120299
120321
|
const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
|
|
120300
120322
|
if (hook == null ? void 0 : hook.token) {
|
|
@@ -120329,6 +120351,175 @@ function createLocalWorld(args) {
|
|
|
120329
120351
|
}
|
|
120330
120352
|
};
|
|
120331
120353
|
}
|
|
120354
|
+
let _dispatcher;
|
|
120355
|
+
let _eventsDispatcher;
|
|
120356
|
+
let _streamDispatcher;
|
|
120357
|
+
let _streamCloseDispatcher;
|
|
120358
|
+
const DEFAULT_HEADERS_TIMEOUT_MS = 3e4;
|
|
120359
|
+
const DEFAULT_BODY_TIMEOUT_MS = 3e4;
|
|
120360
|
+
function envTimeoutMs(name2, fallback) {
|
|
120361
|
+
const raw2 = process.env[name2];
|
|
120362
|
+
if (raw2 === void 0 || raw2 === "")
|
|
120363
|
+
return fallback;
|
|
120364
|
+
const parsed = Number.parseInt(raw2, 10);
|
|
120365
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
|
|
120366
|
+
}
|
|
120367
|
+
const RETRY_ERROR_CODES = [
|
|
120368
|
+
"ECONNRESET",
|
|
120369
|
+
"ECONNREFUSED",
|
|
120370
|
+
"ENOTFOUND",
|
|
120371
|
+
"ENETDOWN",
|
|
120372
|
+
"ENETUNREACH",
|
|
120373
|
+
"EHOSTDOWN",
|
|
120374
|
+
"EHOSTUNREACH",
|
|
120375
|
+
"EPIPE",
|
|
120376
|
+
"UND_ERR_SOCKET",
|
|
120377
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
120378
|
+
"UND_ERR_BODY_TIMEOUT"
|
|
120379
|
+
];
|
|
120380
|
+
const MAX_RETRIES = 2;
|
|
120381
|
+
function getBaseAgentOptions() {
|
|
120382
|
+
return {
|
|
120383
|
+
connections: 8,
|
|
120384
|
+
keepAliveTimeout: 1e4,
|
|
120385
|
+
headersTimeout: envTimeoutMs("WORKFLOW_VERCEL_HEADERS_TIMEOUT_MS", DEFAULT_HEADERS_TIMEOUT_MS),
|
|
120386
|
+
bodyTimeout: envTimeoutMs("WORKFLOW_VERCEL_BODY_TIMEOUT_MS", DEFAULT_BODY_TIMEOUT_MS)
|
|
120387
|
+
};
|
|
120388
|
+
}
|
|
120389
|
+
const H2_MAX_IN_FLIGHT_STREAMS = 100;
|
|
120390
|
+
const H2_STREAM_WINDOW_BYTES = 4 * 1024 * 1024;
|
|
120391
|
+
const H2_CONNECTION_WINDOW_BYTES = 16 * 1024 * 1024;
|
|
120392
|
+
function getAgentOptions() {
|
|
120393
|
+
return {
|
|
120394
|
+
...getBaseAgentOptions(),
|
|
120395
|
+
allowH2: false,
|
|
120396
|
+
// HTTP/1.1 pipelining is disabled (pipelining: 1) because it causes
|
|
120397
|
+
// head-of-line blocking that deadlocks the webhook respondWith mechanism.
|
|
120398
|
+
pipelining: 1
|
|
120399
|
+
};
|
|
120400
|
+
}
|
|
120401
|
+
function getEventsAgentOptions() {
|
|
120402
|
+
return {
|
|
120403
|
+
...getBaseAgentOptions(),
|
|
120404
|
+
allowH2: true,
|
|
120405
|
+
pipelining: H2_MAX_IN_FLIGHT_STREAMS,
|
|
120406
|
+
initialWindowSize: H2_STREAM_WINDOW_BYTES,
|
|
120407
|
+
connectionWindowSize: H2_CONNECTION_WINDOW_BYTES
|
|
120408
|
+
};
|
|
120409
|
+
}
|
|
120410
|
+
function getStreamAgentOptions() {
|
|
120411
|
+
return {
|
|
120412
|
+
...getBaseAgentOptions(),
|
|
120413
|
+
allowH2: true,
|
|
120414
|
+
pipelining: 1
|
|
120415
|
+
};
|
|
120416
|
+
}
|
|
120417
|
+
function getRetryAgentOptions() {
|
|
120418
|
+
return {
|
|
120419
|
+
// Observe Retry-After header if received
|
|
120420
|
+
retryAfter: true,
|
|
120421
|
+
// Retry 5xx in-process (genuine transient blips recover fast), but NOT
|
|
120422
|
+
// 429. The Vercel firewall issues a challenge as a 429: our
|
|
120423
|
+
// server-to-server client cannot solve a challenge, so in-process
|
|
120424
|
+
// retries just re-trigger it ~5× per request and amplify load against
|
|
120425
|
+
// an already-overloaded firewall during an incident. Letting 429 pass
|
|
120426
|
+
// through surfaces it immediately to makeRequest — which maps it to a
|
|
120427
|
+
// ThrottleError carrying the `x-vercel-mitigated` / `x-vercel-id`
|
|
120428
|
+
// headers — and the queue does the (backed-off) retry instead.
|
|
120429
|
+
// (undici default is [500, 502, 503, 504, 429].)
|
|
120430
|
+
statusCodes: [500, 502, 503, 504],
|
|
120431
|
+
errorCodes: RETRY_ERROR_CODES,
|
|
120432
|
+
maxRetries: MAX_RETRIES
|
|
120433
|
+
};
|
|
120434
|
+
}
|
|
120435
|
+
const STREAM_RETRY_OPTIONS = {
|
|
120436
|
+
retryAfter: true,
|
|
120437
|
+
methods: ["PUT"],
|
|
120438
|
+
statusCodes: [429]
|
|
120439
|
+
};
|
|
120440
|
+
const STREAM_CLOSE_RETRY_OPTIONS = {
|
|
120441
|
+
retryAfter: true,
|
|
120442
|
+
methods: ["PUT"],
|
|
120443
|
+
statusCodes: [429, 500, 502, 503, 504]
|
|
120444
|
+
};
|
|
120445
|
+
const H2_REBUFFER_MAX_BYTES = 1 << 20;
|
|
120446
|
+
function h2MultiplexEnabled() {
|
|
120447
|
+
return process.env.WORKFLOW_H2_MULTIPLEX !== "0";
|
|
120448
|
+
}
|
|
120449
|
+
function contentLength(headers2) {
|
|
120450
|
+
if (!headers2 || typeof headers2 !== "object" || Array.isArray(headers2)) {
|
|
120451
|
+
return Number.NaN;
|
|
120452
|
+
}
|
|
120453
|
+
const record2 = headers2;
|
|
120454
|
+
const raw2 = record2["content-length"] ?? record2["Content-Length"];
|
|
120455
|
+
return typeof raw2 === "string" || typeof raw2 === "number" ? Number(raw2) : Number.NaN;
|
|
120456
|
+
}
|
|
120457
|
+
function h2MultiplexInterceptor(dispatch2) {
|
|
120458
|
+
return (opts, handler) => {
|
|
120459
|
+
const body2 = opts.body;
|
|
120460
|
+
const isAsyncIterable = !!body2 && typeof body2 !== "string" && !Buffer.isBuffer(body2) && typeof body2[Symbol.asyncIterator] === "function";
|
|
120461
|
+
const length = contentLength(opts.headers);
|
|
120462
|
+
if (!isAsyncIterable || !(length >= 0) || length > H2_REBUFFER_MAX_BYTES) {
|
|
120463
|
+
return dispatch2({ ...opts, idempotent: true }, handler);
|
|
120464
|
+
}
|
|
120465
|
+
void (async () => {
|
|
120466
|
+
var _a3;
|
|
120467
|
+
try {
|
|
120468
|
+
const chunks = [];
|
|
120469
|
+
for await (const chunk of body2) {
|
|
120470
|
+
chunks.push(Buffer.from(chunk));
|
|
120471
|
+
}
|
|
120472
|
+
dispatch2({ ...opts, body: Buffer.concat(chunks), idempotent: true }, handler);
|
|
120473
|
+
} catch (error2) {
|
|
120474
|
+
(_a3 = handler.onError) == null ? void 0 : _a3.call(handler, error2);
|
|
120475
|
+
}
|
|
120476
|
+
})();
|
|
120477
|
+
return true;
|
|
120478
|
+
};
|
|
120479
|
+
}
|
|
120480
|
+
function getDispatcher(config2) {
|
|
120481
|
+
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
|
|
120482
|
+
}
|
|
120483
|
+
function getEventsDispatcher(config2) {
|
|
120484
|
+
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultEventsDispatcher();
|
|
120485
|
+
}
|
|
120486
|
+
function getStreamDispatcher(config2) {
|
|
120487
|
+
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamDispatcher();
|
|
120488
|
+
}
|
|
120489
|
+
function getStreamCloseDispatcher(config2) {
|
|
120490
|
+
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamCloseDispatcher();
|
|
120491
|
+
}
|
|
120492
|
+
function createEventsDispatcher(agentOverrides) {
|
|
120493
|
+
const agent2 = new undiciExports.RetryAgent(new undiciExports.Agent({ ...getEventsAgentOptions(), ...agentOverrides }), getRetryAgentOptions());
|
|
120494
|
+
if (!h2MultiplexEnabled()) {
|
|
120495
|
+
return agent2;
|
|
120496
|
+
}
|
|
120497
|
+
return withBoundLifecycle(agent2, agent2.compose(h2MultiplexInterceptor));
|
|
120498
|
+
}
|
|
120499
|
+
function withBoundLifecycle(agent2, composed) {
|
|
120500
|
+
return new Proxy(composed, {
|
|
120501
|
+
get: (target2, key) => key === "close" || key === "destroy" ? agent2[key].bind(agent2) : target2[key]
|
|
120502
|
+
});
|
|
120503
|
+
}
|
|
120504
|
+
function createStreamDispatcher(retryOptions, agentOverrides) {
|
|
120505
|
+
return new undiciExports.RetryAgent(new undiciExports.Agent({ ...getStreamAgentOptions(), ...agentOverrides }), retryOptions);
|
|
120506
|
+
}
|
|
120507
|
+
function getDefaultDispatcher() {
|
|
120508
|
+
_dispatcher ?? (_dispatcher = new undiciExports.RetryAgent(new undiciExports.Agent(getAgentOptions()), getRetryAgentOptions()));
|
|
120509
|
+
return _dispatcher;
|
|
120510
|
+
}
|
|
120511
|
+
function getDefaultEventsDispatcher() {
|
|
120512
|
+
_eventsDispatcher ?? (_eventsDispatcher = createEventsDispatcher());
|
|
120513
|
+
return _eventsDispatcher;
|
|
120514
|
+
}
|
|
120515
|
+
function getDefaultStreamDispatcher() {
|
|
120516
|
+
_streamDispatcher ?? (_streamDispatcher = createStreamDispatcher(STREAM_RETRY_OPTIONS));
|
|
120517
|
+
return _streamDispatcher;
|
|
120518
|
+
}
|
|
120519
|
+
function getDefaultStreamCloseDispatcher() {
|
|
120520
|
+
_streamCloseDispatcher ?? (_streamCloseDispatcher = createStreamDispatcher(STREAM_CLOSE_RETRY_OPTIONS));
|
|
120521
|
+
return _streamCloseDispatcher;
|
|
120522
|
+
}
|
|
120332
120523
|
var getContext_1;
|
|
120333
120524
|
var hasRequiredGetContext;
|
|
120334
120525
|
function requireGetContext() {
|
|
@@ -120447,8 +120638,8 @@ function requireGetVercelOidcToken() {
|
|
|
120447
120638
|
}
|
|
120448
120639
|
try {
|
|
120449
120640
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
120450
|
-
await import("./token-util-
|
|
120451
|
-
await import("./token-
|
|
120641
|
+
await import("./token-util-BVCPBo_Y.js").then((n) => n.t),
|
|
120642
|
+
await import("./token-BdngUnpg.js").then((n) => n.t)
|
|
120452
120643
|
]);
|
|
120453
120644
|
if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
|
|
120454
120645
|
await refreshToken(options);
|
|
@@ -121011,38 +121202,220 @@ function requireDist() {
|
|
|
121011
121202
|
return dist;
|
|
121012
121203
|
}
|
|
121013
121204
|
var distExports = requireDist();
|
|
121014
|
-
let
|
|
121015
|
-
function
|
|
121016
|
-
|
|
121205
|
+
let otelApiPromise = null;
|
|
121206
|
+
async function getOtelApi() {
|
|
121207
|
+
if (!otelApiPromise) {
|
|
121208
|
+
otelApiPromise = import("./index-hBO56emR.js").catch(() => null);
|
|
121209
|
+
}
|
|
121210
|
+
return otelApiPromise;
|
|
121017
121211
|
}
|
|
121018
|
-
|
|
121019
|
-
|
|
121020
|
-
|
|
121021
|
-
|
|
121022
|
-
keepAliveTimeout: 1e4,
|
|
121023
|
-
// H2 is specifically incompatible with SvelteKit on Vercel prod. Everything else
|
|
121024
|
-
// runs fine.
|
|
121025
|
-
// TODO: Investigate/fix the failure on SvelteKit so we can re-enable H2.
|
|
121026
|
-
allowH2: false,
|
|
121027
|
-
// HTTP/1.1 pipelining is disabled (pipelining: 1) because it causes
|
|
121028
|
-
// head-of-line blocking that deadlocks the webhook respondWith mechanism.
|
|
121029
|
-
pipelining: 1
|
|
121030
|
-
}), {
|
|
121031
|
-
// Observe Retry-After header if received
|
|
121032
|
-
retryAfter: true,
|
|
121033
|
-
// Retry 5xx in-process (genuine transient blips recover fast), but NOT
|
|
121034
|
-
// 429. The Vercel firewall issues a challenge as a 429: our
|
|
121035
|
-
// server-to-server client cannot solve a challenge, so in-process
|
|
121036
|
-
// retries just re-trigger it ~5× per request and amplify load against
|
|
121037
|
-
// an already-overloaded firewall during an incident. Letting 429 pass
|
|
121038
|
-
// through surfaces it immediately to makeRequest — which maps it to a
|
|
121039
|
-
// ThrottleError carrying the `x-vercel-mitigated` / `x-vercel-id`
|
|
121040
|
-
// headers — and the queue does the (backed-off) retry instead.
|
|
121041
|
-
// (undici default is [500, 502, 503, 504, 429].)
|
|
121042
|
-
statusCodes: [500, 502, 503, 504]
|
|
121043
|
-
});
|
|
121212
|
+
let tracerPromise = null;
|
|
121213
|
+
async function getTracer() {
|
|
121214
|
+
if (!tracerPromise) {
|
|
121215
|
+
tracerPromise = getOtelApi().then((otel) => otel ? otel.trace.getTracer("workflow") : null);
|
|
121044
121216
|
}
|
|
121045
|
-
return
|
|
121217
|
+
return tracerPromise;
|
|
121218
|
+
}
|
|
121219
|
+
async function trace(spanName2, ...args) {
|
|
121220
|
+
const [tracer, otel] = await Promise.all([getTracer(), getOtelApi()]);
|
|
121221
|
+
const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
|
|
121222
|
+
if (!fn2)
|
|
121223
|
+
throw new Error("Function to trace must be provided");
|
|
121224
|
+
if (!tracer || !otel) {
|
|
121225
|
+
return await fn2();
|
|
121226
|
+
}
|
|
121227
|
+
return tracer.startActiveSpan(spanName2, opts, async (span) => {
|
|
121228
|
+
try {
|
|
121229
|
+
const result = await fn2(span);
|
|
121230
|
+
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
121231
|
+
return result;
|
|
121232
|
+
} catch (e) {
|
|
121233
|
+
span.setStatus({
|
|
121234
|
+
code: otel.SpanStatusCode.ERROR,
|
|
121235
|
+
message: e.message
|
|
121236
|
+
});
|
|
121237
|
+
throw e;
|
|
121238
|
+
} finally {
|
|
121239
|
+
span.end();
|
|
121240
|
+
}
|
|
121241
|
+
});
|
|
121242
|
+
}
|
|
121243
|
+
async function getSpanKind(field) {
|
|
121244
|
+
const otel = await getOtelApi();
|
|
121245
|
+
if (!otel)
|
|
121246
|
+
return void 0;
|
|
121247
|
+
return otel.SpanKind[field];
|
|
121248
|
+
}
|
|
121249
|
+
async function injectTraceContextIntoHeaders(headers2) {
|
|
121250
|
+
const otel = await getOtelApi();
|
|
121251
|
+
if (!otel)
|
|
121252
|
+
return;
|
|
121253
|
+
const carrier = {};
|
|
121254
|
+
otel.propagation.inject(otel.context.active(), carrier);
|
|
121255
|
+
for (const [key, value] of Object.entries(carrier)) {
|
|
121256
|
+
headers2.set(key, value);
|
|
121257
|
+
}
|
|
121258
|
+
}
|
|
121259
|
+
function SemanticConvention(...names) {
|
|
121260
|
+
return (value) => Object.fromEntries(names.map((name2) => [name2, value]));
|
|
121261
|
+
}
|
|
121262
|
+
const HttpRequestMethod = SemanticConvention("http.request.method");
|
|
121263
|
+
const UrlFull = SemanticConvention("url.full");
|
|
121264
|
+
const ServerAddress = SemanticConvention("server.address");
|
|
121265
|
+
const ServerPort = SemanticConvention("server.port");
|
|
121266
|
+
const HttpResponseStatusCode = SemanticConvention("http.response.status_code");
|
|
121267
|
+
const ErrorType = SemanticConvention("error.type");
|
|
121268
|
+
const WorldParseFormat = SemanticConvention("workflow.world.parse.format");
|
|
121269
|
+
const PeerService = SemanticConvention("peer.service");
|
|
121270
|
+
const RpcSystem = SemanticConvention("rpc.system");
|
|
121271
|
+
const RpcService = SemanticConvention("rpc.service");
|
|
121272
|
+
const RpcMethod = SemanticConvention("rpc.method");
|
|
121273
|
+
const WorkflowRunId = SemanticConvention("workflow.run.id");
|
|
121274
|
+
const StepId = SemanticConvention("step.id");
|
|
121275
|
+
const REQUEST_TIMEOUT_MS = 6e4;
|
|
121276
|
+
const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
121277
|
+
const DIAGNOSTIC_HEADERS = [
|
|
121278
|
+
"x-vercel-id",
|
|
121279
|
+
"x-vercel-error",
|
|
121280
|
+
"x-vercel-mitigated"
|
|
121281
|
+
];
|
|
121282
|
+
function getVercelDiagnostics(headers2) {
|
|
121283
|
+
return DIAGNOSTIC_HEADERS.flatMap((header) => {
|
|
121284
|
+
const value = headers2.get(header);
|
|
121285
|
+
return value ? [`${header}=${value}`] : [];
|
|
121286
|
+
});
|
|
121287
|
+
}
|
|
121288
|
+
function formatVercelDiagnostics(headers2) {
|
|
121289
|
+
const diagnostics2 = getVercelDiagnostics(headers2);
|
|
121290
|
+
return diagnostics2.length > 0 ? ` (${diagnostics2.join("; ")})` : "";
|
|
121291
|
+
}
|
|
121292
|
+
function httpLog(method, label, response2, ms2) {
|
|
121293
|
+
if (!HTTP_DEBUG_ENABLED)
|
|
121294
|
+
return;
|
|
121295
|
+
const diagnostics2 = getVercelDiagnostics(response2.headers);
|
|
121296
|
+
const suffix = diagnostics2.length > 0 ? `; ${diagnostics2.join("; ")}` : "";
|
|
121297
|
+
console.debug(`[workflow:world-vercel:http] ${method} ${label} -> ${response2.status} (${ms2}ms${suffix})`);
|
|
121298
|
+
}
|
|
121299
|
+
function logCurlRepro(method, url2, headers2) {
|
|
121300
|
+
if (!process.env.DEBUG)
|
|
121301
|
+
return;
|
|
121302
|
+
const stringifiedHeaders = Array.from(headers2.entries()).filter(([key]) => key.toLowerCase() !== "authorization").map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
|
|
121303
|
+
console.error(`Failed to fetch, reproduce with:
|
|
121304
|
+
curl -X ${method} ${stringifiedHeaders} "${url2}"`);
|
|
121305
|
+
}
|
|
121306
|
+
function parseRetryAfter(value) {
|
|
121307
|
+
if (!value)
|
|
121308
|
+
return void 0;
|
|
121309
|
+
const parsed = parseInt(value, 10);
|
|
121310
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
121311
|
+
}
|
|
121312
|
+
function errorForResponse(status, message2, opts = {}) {
|
|
121313
|
+
const { retryAfter, code: code2, url: url2, mitigated } = opts;
|
|
121314
|
+
if (status === 409)
|
|
121315
|
+
return new EntityConflictError(message2);
|
|
121316
|
+
if (status === 410)
|
|
121317
|
+
return new RunExpiredError(message2);
|
|
121318
|
+
if (status === 412)
|
|
121319
|
+
return new PreconditionFailedError(message2, { retryAfter });
|
|
121320
|
+
if (status === 425)
|
|
121321
|
+
return new TooEarlyError(message2, { retryAfter });
|
|
121322
|
+
if (status === 429) {
|
|
121323
|
+
if (isFirewallChallenge429(status, mitigated)) {
|
|
121324
|
+
return new WorkflowWorldError(`${message2} (x-vercel-mitigated=challenge)`, {
|
|
121325
|
+
url: url2,
|
|
121326
|
+
status,
|
|
121327
|
+
code: "TRANSPORT",
|
|
121328
|
+
retryAfter
|
|
121329
|
+
});
|
|
121330
|
+
}
|
|
121331
|
+
return new ThrottleError(message2, { retryAfter });
|
|
121332
|
+
}
|
|
121333
|
+
return new WorkflowWorldError(message2, { url: url2, status, code: code2, retryAfter });
|
|
121334
|
+
}
|
|
121335
|
+
function isFirewallChallenge429(status, mitigated) {
|
|
121336
|
+
return status === 429 && mitigated === "challenge";
|
|
121337
|
+
}
|
|
121338
|
+
async function resolveVercelApiToken(opts) {
|
|
121339
|
+
return (opts == null ? void 0 : opts.token) ?? process.env.VERCEL_TOKEN ?? await distExports.getVercelOidcToken().catch(() => null);
|
|
121340
|
+
}
|
|
121341
|
+
function parseServer(url2) {
|
|
121342
|
+
try {
|
|
121343
|
+
const parsed = new URL(url2);
|
|
121344
|
+
return {
|
|
121345
|
+
serverAddress: parsed.hostname,
|
|
121346
|
+
serverPort: parsed.port ? parseInt(parsed.port, 10) : parsed.protocol === "https:" ? 443 : 80
|
|
121347
|
+
};
|
|
121348
|
+
} catch {
|
|
121349
|
+
return {};
|
|
121350
|
+
}
|
|
121351
|
+
}
|
|
121352
|
+
function httpClientSpanAttributes(args) {
|
|
121353
|
+
const { method, url: url2, peerService } = args;
|
|
121354
|
+
const { serverAddress, serverPort } = parseServer(url2);
|
|
121355
|
+
return {
|
|
121356
|
+
...HttpRequestMethod(method),
|
|
121357
|
+
...UrlFull(url2),
|
|
121358
|
+
...serverAddress ? ServerAddress(serverAddress) : {},
|
|
121359
|
+
...serverPort ? ServerPort(serverPort) : {},
|
|
121360
|
+
...PeerService(peerService),
|
|
121361
|
+
...RpcSystem("http"),
|
|
121362
|
+
...RpcService(peerService)
|
|
121363
|
+
};
|
|
121364
|
+
}
|
|
121365
|
+
async function instrumentedFetch(opts) {
|
|
121366
|
+
const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError } = opts;
|
|
121367
|
+
const label = logLabel ?? url2;
|
|
121368
|
+
return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
|
|
121369
|
+
var _a3, _b2, _c;
|
|
121370
|
+
span == null ? void 0 : span.setAttributes(httpClientSpanAttributes({ method, url: url2, peerService }));
|
|
121371
|
+
if (injectTraceContext)
|
|
121372
|
+
await injectTraceContextIntoHeaders(headers2);
|
|
121373
|
+
if (cacheBust)
|
|
121374
|
+
headers2.set("X-Request-Time", Date.now().toString());
|
|
121375
|
+
const timeoutSignal = timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0;
|
|
121376
|
+
const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
|
|
121377
|
+
const start2 = Date.now();
|
|
121378
|
+
let response2;
|
|
121379
|
+
try {
|
|
121380
|
+
response2 = await fetch(url2, {
|
|
121381
|
+
method,
|
|
121382
|
+
headers: headers2,
|
|
121383
|
+
body: body2,
|
|
121384
|
+
signal,
|
|
121385
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici dispatcher type doesn't match @types/node's RequestInit
|
|
121386
|
+
dispatcher: dispatcher2
|
|
121387
|
+
});
|
|
121388
|
+
} catch (error2) {
|
|
121389
|
+
const elapsed = Date.now() - start2;
|
|
121390
|
+
if (error2 instanceof Error && (error2.name === "TimeoutError" || error2.name === "AbortError")) {
|
|
121391
|
+
const timeoutError = new WorkflowWorldError(`${method} ${label} timed out after ${elapsed}ms`, { url: url2, cause: error2 });
|
|
121392
|
+
span == null ? void 0 : span.setAttributes({ ...ErrorType("TIMEOUT") });
|
|
121393
|
+
(_a3 = span == null ? void 0 : span.recordException) == null ? void 0 : _a3.call(span, timeoutError);
|
|
121394
|
+
throw timeoutError;
|
|
121395
|
+
}
|
|
121396
|
+
throw error2;
|
|
121397
|
+
}
|
|
121398
|
+
const ms2 = Date.now() - start2;
|
|
121399
|
+
httpLog(method, label, response2, ms2);
|
|
121400
|
+
span == null ? void 0 : span.setAttributes({ ...HttpResponseStatusCode(response2.status) });
|
|
121401
|
+
if (!response2.ok) {
|
|
121402
|
+
span == null ? void 0 : span.setAttributes({ ...ErrorType(`HTTP ${response2.status}`) });
|
|
121403
|
+
logCurlRepro(method, url2, headers2);
|
|
121404
|
+
if (buildError) {
|
|
121405
|
+
const error3 = await buildError(response2);
|
|
121406
|
+
(_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, error3);
|
|
121407
|
+
throw error3;
|
|
121408
|
+
}
|
|
121409
|
+
const text2 = await response2.text().catch(() => "");
|
|
121410
|
+
const error2 = errorForResponse(response2.status, `${method} ${label} -> HTTP ${response2.status}: ${response2.statusText}${text2 ? ` ${text2}` : ""}${formatVercelDiagnostics(response2.headers)}`, {
|
|
121411
|
+
url: url2,
|
|
121412
|
+
retryAfter: parseRetryAfter(response2.headers.get("Retry-After"))
|
|
121413
|
+
});
|
|
121414
|
+
(_c = span == null ? void 0 : span.recordException) == null ? void 0 : _c.call(span, error2);
|
|
121415
|
+
throw error2;
|
|
121416
|
+
}
|
|
121417
|
+
return response2;
|
|
121418
|
+
});
|
|
121046
121419
|
}
|
|
121047
121420
|
const KEY_BYTES = 32;
|
|
121048
121421
|
async function deriveRunKey(deploymentKey, projectId, runId) {
|
|
@@ -121068,7 +121441,7 @@ async function deriveRunKey(deploymentKey, projectId, runId) {
|
|
|
121068
121441
|
return new Uint8Array(derivedBits);
|
|
121069
121442
|
}
|
|
121070
121443
|
async function fetchRunKey(deploymentId, projectId, runId, options) {
|
|
121071
|
-
const token = (options == null ? void 0 : options.token
|
|
121444
|
+
const token = await resolveVercelApiToken({ token: options == null ? void 0 : options.token });
|
|
121072
121445
|
if (!token) {
|
|
121073
121446
|
throw new Error("Cannot fetch run key: no OIDC token or VERCEL_TOKEN available");
|
|
121074
121447
|
}
|
|
@@ -121076,23 +121449,25 @@ async function fetchRunKey(deploymentId, projectId, runId, options) {
|
|
|
121076
121449
|
if (options == null ? void 0 : options.teamId) {
|
|
121077
121450
|
params.set("teamId", options.teamId);
|
|
121078
121451
|
}
|
|
121079
|
-
const response2 = await
|
|
121452
|
+
const response2 = await instrumentedFetch({
|
|
121080
121453
|
method: "GET",
|
|
121081
|
-
|
|
121082
|
-
|
|
121083
|
-
},
|
|
121084
|
-
|
|
121085
|
-
|
|
121086
|
-
|
|
121087
|
-
|
|
121088
|
-
|
|
121089
|
-
|
|
121090
|
-
|
|
121091
|
-
|
|
121092
|
-
|
|
121454
|
+
url: `https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`,
|
|
121455
|
+
headers: new Headers({ Authorization: `Bearer ${token}` }),
|
|
121456
|
+
dispatcher: getDispatcher({ dispatcher: options == null ? void 0 : options.dispatcher }),
|
|
121457
|
+
peerService: "vercel-api",
|
|
121458
|
+
// Preserve the prior no-timeout behavior for this Vercel-API call; the
|
|
121459
|
+
// shared RetryAgent still handles transient/5xx retries.
|
|
121460
|
+
timeoutMs: null,
|
|
121461
|
+
buildError: async (res) => {
|
|
121462
|
+
let body2;
|
|
121463
|
+
try {
|
|
121464
|
+
body2 = await res.text();
|
|
121465
|
+
} catch {
|
|
121466
|
+
body2 = "<unable to read response body>";
|
|
121467
|
+
}
|
|
121468
|
+
return new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`);
|
|
121093
121469
|
}
|
|
121094
|
-
|
|
121095
|
-
}
|
|
121470
|
+
});
|
|
121096
121471
|
const data = await response2.json();
|
|
121097
121472
|
const result = object$1({ key: string$3().nullable() }).safeParse(data);
|
|
121098
121473
|
if (!result.success) {
|
|
@@ -121137,66 +121512,6 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
|
|
|
121137
121512
|
});
|
|
121138
121513
|
};
|
|
121139
121514
|
}
|
|
121140
|
-
let otelApiPromise = null;
|
|
121141
|
-
async function getOtelApi() {
|
|
121142
|
-
if (!otelApiPromise) {
|
|
121143
|
-
otelApiPromise = import("./index-meg9qk8y.js").catch(() => null);
|
|
121144
|
-
}
|
|
121145
|
-
return otelApiPromise;
|
|
121146
|
-
}
|
|
121147
|
-
let tracerPromise = null;
|
|
121148
|
-
async function getTracer() {
|
|
121149
|
-
if (!tracerPromise) {
|
|
121150
|
-
tracerPromise = getOtelApi().then((otel) => otel ? otel.trace.getTracer("workflow") : null);
|
|
121151
|
-
}
|
|
121152
|
-
return tracerPromise;
|
|
121153
|
-
}
|
|
121154
|
-
async function trace(spanName2, ...args) {
|
|
121155
|
-
const [tracer, otel] = await Promise.all([getTracer(), getOtelApi()]);
|
|
121156
|
-
const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
|
|
121157
|
-
if (!fn2)
|
|
121158
|
-
throw new Error("Function to trace must be provided");
|
|
121159
|
-
if (!tracer || !otel) {
|
|
121160
|
-
return await fn2();
|
|
121161
|
-
}
|
|
121162
|
-
return tracer.startActiveSpan(spanName2, opts, async (span) => {
|
|
121163
|
-
try {
|
|
121164
|
-
const result = await fn2(span);
|
|
121165
|
-
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
121166
|
-
return result;
|
|
121167
|
-
} catch (e) {
|
|
121168
|
-
span.setStatus({
|
|
121169
|
-
code: otel.SpanStatusCode.ERROR,
|
|
121170
|
-
message: e.message
|
|
121171
|
-
});
|
|
121172
|
-
throw e;
|
|
121173
|
-
} finally {
|
|
121174
|
-
span.end();
|
|
121175
|
-
}
|
|
121176
|
-
});
|
|
121177
|
-
}
|
|
121178
|
-
async function getSpanKind(field) {
|
|
121179
|
-
const otel = await getOtelApi();
|
|
121180
|
-
if (!otel)
|
|
121181
|
-
return void 0;
|
|
121182
|
-
return otel.SpanKind[field];
|
|
121183
|
-
}
|
|
121184
|
-
function SemanticConvention(...names) {
|
|
121185
|
-
return (value) => Object.fromEntries(names.map((name2) => [name2, value]));
|
|
121186
|
-
}
|
|
121187
|
-
const HttpRequestMethod = SemanticConvention("http.request.method");
|
|
121188
|
-
const UrlFull = SemanticConvention("url.full");
|
|
121189
|
-
const ServerAddress = SemanticConvention("server.address");
|
|
121190
|
-
const ServerPort = SemanticConvention("server.port");
|
|
121191
|
-
const HttpResponseStatusCode = SemanticConvention("http.response.status_code");
|
|
121192
|
-
const ErrorType = SemanticConvention("error.type");
|
|
121193
|
-
const WorldParseFormat = SemanticConvention("workflow.world.parse.format");
|
|
121194
|
-
const PeerService = SemanticConvention("peer.service");
|
|
121195
|
-
const RpcSystem = SemanticConvention("rpc.system");
|
|
121196
|
-
const RpcService = SemanticConvention("rpc.service");
|
|
121197
|
-
const RpcMethod = SemanticConvention("rpc.method");
|
|
121198
|
-
const WorkflowRunId = SemanticConvention("workflow.run.id");
|
|
121199
|
-
const StepId = SemanticConvention("step.id");
|
|
121200
121515
|
const WORKFLOW_SERVER_SERVICE = {
|
|
121201
121516
|
peerService: "workflow-server",
|
|
121202
121517
|
rpcSystem: "http",
|
|
@@ -125793,26 +126108,7 @@ var QueueClient = class {
|
|
|
125793
126108
|
setApi(this, new ApiClient({ ...options, region }));
|
|
125794
126109
|
}
|
|
125795
126110
|
};
|
|
125796
|
-
const version = "4.
|
|
125797
|
-
const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
125798
|
-
function httpLog(method, endpoint, response2, ms2) {
|
|
125799
|
-
if (HTTP_DEBUG_ENABLED) {
|
|
125800
|
-
const responseContext = getResponseDiagnosticHeaders(response2);
|
|
125801
|
-
const diagnosticSuffix = responseContext.length > 0 ? `; ${responseContext.join("; ")}` : "";
|
|
125802
|
-
console.debug(`[workflow:world-vercel:http] ${method} ${endpoint} -> ${response2.status} (${ms2}ms${diagnosticSuffix})`);
|
|
125803
|
-
}
|
|
125804
|
-
}
|
|
125805
|
-
function getResponseDiagnosticHeaders(response2) {
|
|
125806
|
-
return ["x-vercel-id", "x-vercel-error", "x-vercel-mitigated"].flatMap((header) => {
|
|
125807
|
-
const value = response2.headers.get(header);
|
|
125808
|
-
return value ? [`${header}=${value}`] : [];
|
|
125809
|
-
});
|
|
125810
|
-
}
|
|
125811
|
-
function formatResponseDiagnostics(response2) {
|
|
125812
|
-
const headers2 = getResponseDiagnosticHeaders(response2);
|
|
125813
|
-
return headers2.length > 0 ? ` (${headers2.join("; ")})` : "";
|
|
125814
|
-
}
|
|
125815
|
-
const REQUEST_TIMEOUT_MS = 6e4;
|
|
126111
|
+
const version = "4.6.1";
|
|
125816
126112
|
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
125817
126113
|
const MAX_BODY_PARSE_RETRIES = 2;
|
|
125818
126114
|
const BODY_PARSE_RETRY_BASE_MS = 100;
|
|
@@ -125950,27 +126246,15 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
|
|
|
125950
126246
|
const method = options.method || "GET";
|
|
125951
126247
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
125952
126248
|
const url2 = `${baseUrl}${endpoint}`;
|
|
125953
|
-
let serverAddress;
|
|
125954
|
-
let serverPort;
|
|
125955
|
-
try {
|
|
125956
|
-
const parsedUrl = new URL(url2);
|
|
125957
|
-
serverAddress = parsedUrl.hostname;
|
|
125958
|
-
serverPort = parsedUrl.port ? parseInt(parsedUrl.port, 10) : parsedUrl.protocol === "https:" ? 443 : 80;
|
|
125959
|
-
} catch {
|
|
125960
|
-
}
|
|
125961
126249
|
return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
|
|
125962
|
-
var _a3, _b2;
|
|
125963
|
-
span == null ? void 0 : span.setAttributes({
|
|
125964
|
-
|
|
125965
|
-
|
|
125966
|
-
|
|
125967
|
-
|
|
125968
|
-
// Peer service for Datadog service maps
|
|
125969
|
-
...PeerService("workflow-server"),
|
|
125970
|
-
...RpcSystem("http"),
|
|
125971
|
-
...RpcService("workflow-server")
|
|
125972
|
-
});
|
|
126250
|
+
var _a3, _b2, _c;
|
|
126251
|
+
span == null ? void 0 : span.setAttributes(httpClientSpanAttributes({
|
|
126252
|
+
method,
|
|
126253
|
+
url: url2,
|
|
126254
|
+
peerService: "workflow-server"
|
|
126255
|
+
}));
|
|
125973
126256
|
headers2.set("Accept", "application/cbor");
|
|
126257
|
+
await injectTraceContextIntoHeaders(headers2);
|
|
125974
126258
|
let body2;
|
|
125975
126259
|
if (data !== void 0) {
|
|
125976
126260
|
headers2.set("Content-Type", "application/cbor");
|
|
@@ -126017,61 +126301,27 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
|
|
|
126017
126301
|
throw error2;
|
|
126018
126302
|
}
|
|
126019
126303
|
const fetchMs = Date.now() - fetchStart;
|
|
126020
|
-
responseDiagnostics =
|
|
126304
|
+
responseDiagnostics = formatVercelDiagnostics(response2.headers);
|
|
126021
126305
|
httpLog(method, endpoint, response2, fetchMs);
|
|
126022
126306
|
span == null ? void 0 : span.setAttributes({
|
|
126023
126307
|
...HttpResponseStatusCode(response2.status)
|
|
126024
126308
|
});
|
|
126025
126309
|
if (!response2.ok) {
|
|
126026
126310
|
const errorData = await parseResponseBody(response2).then((r2) => r2.data).catch(() => ({}));
|
|
126027
|
-
|
|
126028
|
-
|
|
126029
|
-
console.error(`Failed to fetch, reproduce with:
|
|
126030
|
-
curl -X ${request2.method} ${stringifiedHeaders} "${url2}"`);
|
|
126031
|
-
}
|
|
126032
|
-
let retryAfter;
|
|
126033
|
-
const retryAfterHeader = response2.headers.get("Retry-After");
|
|
126034
|
-
if (retryAfterHeader) {
|
|
126035
|
-
const parsed = parseInt(retryAfterHeader, 10);
|
|
126036
|
-
if (!Number.isNaN(parsed)) {
|
|
126037
|
-
retryAfter = parsed;
|
|
126038
|
-
}
|
|
126039
|
-
}
|
|
126311
|
+
logCurlRepro(request2.method, url2, headers2);
|
|
126312
|
+
const retryAfter = parseRetryAfter(response2.headers.get("Retry-After"));
|
|
126040
126313
|
const defaultMessage = (errorData.message || `${request2.method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`) + responseDiagnostics;
|
|
126041
|
-
const
|
|
126042
|
-
var _a4;
|
|
126043
|
-
span == null ? void 0 : span.setAttributes({
|
|
126044
|
-
...ErrorType(errorData.code || `HTTP ${response2.status}`)
|
|
126045
|
-
});
|
|
126046
|
-
(_a4 = span == null ? void 0 : span.recordException) == null ? void 0 : _a4.call(span, error2);
|
|
126047
|
-
throw error2;
|
|
126048
|
-
};
|
|
126049
|
-
if (response2.status === 409) {
|
|
126050
|
-
throwWithTrace(new EntityConflictError(defaultMessage));
|
|
126051
|
-
}
|
|
126052
|
-
if (response2.status === 410) {
|
|
126053
|
-
throwWithTrace(new RunExpiredError(defaultMessage));
|
|
126054
|
-
}
|
|
126055
|
-
if (response2.status === 425) {
|
|
126056
|
-
throwWithTrace(new TooEarlyError(defaultMessage, { retryAfter }));
|
|
126057
|
-
}
|
|
126058
|
-
if (response2.status === 429) {
|
|
126059
|
-
if (response2.headers.get("x-vercel-mitigated") === "challenge") {
|
|
126060
|
-
throwWithTrace(new WorkflowWorldError(`${defaultMessage} (x-vercel-mitigated=challenge)`, {
|
|
126061
|
-
url: url2,
|
|
126062
|
-
status: response2.status,
|
|
126063
|
-
code: "TRANSPORT",
|
|
126064
|
-
retryAfter
|
|
126065
|
-
}));
|
|
126066
|
-
}
|
|
126067
|
-
throwWithTrace(new ThrottleError(defaultMessage, { retryAfter }));
|
|
126068
|
-
}
|
|
126069
|
-
throwWithTrace(new WorkflowWorldError(defaultMessage, {
|
|
126314
|
+
const error2 = errorForResponse(response2.status, defaultMessage, {
|
|
126070
126315
|
url: url2,
|
|
126071
|
-
status: response2.status,
|
|
126072
126316
|
code: errorData.code,
|
|
126073
|
-
retryAfter
|
|
126074
|
-
|
|
126317
|
+
retryAfter,
|
|
126318
|
+
mitigated: response2.headers.get("x-vercel-mitigated")
|
|
126319
|
+
});
|
|
126320
|
+
span == null ? void 0 : span.setAttributes({
|
|
126321
|
+
...ErrorType(errorData.code || `HTTP ${response2.status}`)
|
|
126322
|
+
});
|
|
126323
|
+
(_c = span == null ? void 0 : span.recordException) == null ? void 0 : _c.call(span, error2);
|
|
126324
|
+
throw error2;
|
|
126075
126325
|
}
|
|
126076
126326
|
onResponse == null ? void 0 : onResponse(response2);
|
|
126077
126327
|
try {
|
|
@@ -126356,28 +126606,30 @@ function createResolveLatestDeploymentId(config2) {
|
|
|
126356
126606
|
if (!currentDeploymentId) {
|
|
126357
126607
|
throw new Error("Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set");
|
|
126358
126608
|
}
|
|
126359
|
-
const token =
|
|
126609
|
+
const token = await resolveVercelApiToken(config2);
|
|
126360
126610
|
if (!token) {
|
|
126361
126611
|
throw new Error("Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available");
|
|
126362
126612
|
}
|
|
126363
126613
|
const url2 = `https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(currentDeploymentId)}`;
|
|
126364
|
-
const response2 = await
|
|
126614
|
+
const response2 = await instrumentedFetch({
|
|
126365
126615
|
method: "GET",
|
|
126366
|
-
|
|
126367
|
-
|
|
126368
|
-
|
|
126369
|
-
|
|
126370
|
-
|
|
126371
|
-
|
|
126372
|
-
|
|
126373
|
-
|
|
126374
|
-
|
|
126375
|
-
|
|
126376
|
-
|
|
126377
|
-
|
|
126616
|
+
url: url2,
|
|
126617
|
+
headers: new Headers({ Authorization: `Bearer ${token}` }),
|
|
126618
|
+
dispatcher: getDispatcher(config2),
|
|
126619
|
+
peerService: "vercel-api",
|
|
126620
|
+
// Preserve the prior no-timeout behavior for this Vercel-API call; the
|
|
126621
|
+
// shared RetryAgent still handles transient/5xx retries.
|
|
126622
|
+
timeoutMs: null,
|
|
126623
|
+
buildError: async (res) => {
|
|
126624
|
+
let body2;
|
|
126625
|
+
try {
|
|
126626
|
+
body2 = await res.text();
|
|
126627
|
+
} catch {
|
|
126628
|
+
body2 = "<unable to read response body>";
|
|
126629
|
+
}
|
|
126630
|
+
return new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`);
|
|
126378
126631
|
}
|
|
126379
|
-
|
|
126380
|
-
}
|
|
126632
|
+
});
|
|
126381
126633
|
const data = await response2.json();
|
|
126382
126634
|
const result = ResolveLatestDeploymentResponseSchema.safeParse(data);
|
|
126383
126635
|
if (!result.success) {
|
|
@@ -126386,6 +126638,176 @@ function createResolveLatestDeploymentId(config2) {
|
|
|
126386
126638
|
return result.data.id;
|
|
126387
126639
|
};
|
|
126388
126640
|
}
|
|
126641
|
+
const EVENT_RETRY_ELIGIBILITY = {
|
|
126642
|
+
// Creates: conditional create → 409 EntityConflictError if it already exists.
|
|
126643
|
+
run_created: {
|
|
126644
|
+
retryable: true,
|
|
126645
|
+
reason: "conditional create → 409 if exists"
|
|
126646
|
+
},
|
|
126647
|
+
step_created: {
|
|
126648
|
+
retryable: true,
|
|
126649
|
+
reason: "conditional create → 409 if exists"
|
|
126650
|
+
},
|
|
126651
|
+
wait_created: {
|
|
126652
|
+
retryable: true,
|
|
126653
|
+
reason: "conditional create → 409 if exists"
|
|
126654
|
+
},
|
|
126655
|
+
hook_created: {
|
|
126656
|
+
retryable: true,
|
|
126657
|
+
reason: "transactional token uniqueness → 409 if exists"
|
|
126658
|
+
},
|
|
126659
|
+
// Run start: early-returns if already running, writes no duplicate row.
|
|
126660
|
+
run_started: {
|
|
126661
|
+
retryable: true,
|
|
126662
|
+
reason: "early-returns if already running, no duplicate row"
|
|
126663
|
+
},
|
|
126664
|
+
// Terminal transitions: conditional `.where()` excludes terminal states →
|
|
126665
|
+
// 409 before the event row is written.
|
|
126666
|
+
run_completed: {
|
|
126667
|
+
retryable: true,
|
|
126668
|
+
reason: "terminal-state guard → 409, no duplicate row"
|
|
126669
|
+
},
|
|
126670
|
+
run_failed: {
|
|
126671
|
+
retryable: true,
|
|
126672
|
+
reason: "terminal-state guard → 409, no duplicate row"
|
|
126673
|
+
},
|
|
126674
|
+
run_cancelled: {
|
|
126675
|
+
retryable: true,
|
|
126676
|
+
reason: "terminal-state guard → 409, no duplicate row"
|
|
126677
|
+
},
|
|
126678
|
+
step_completed: {
|
|
126679
|
+
retryable: true,
|
|
126680
|
+
reason: "terminal-state guard → 409, no duplicate row"
|
|
126681
|
+
},
|
|
126682
|
+
step_failed: {
|
|
126683
|
+
retryable: true,
|
|
126684
|
+
reason: "terminal-state guard → 409, no duplicate row"
|
|
126685
|
+
},
|
|
126686
|
+
wait_completed: {
|
|
126687
|
+
retryable: true,
|
|
126688
|
+
reason: "waiting-state guard → 409, no duplicate row"
|
|
126689
|
+
},
|
|
126690
|
+
hook_disposed: {
|
|
126691
|
+
retryable: true,
|
|
126692
|
+
reason: "conditional delete (exists) → 409, no duplicate row"
|
|
126693
|
+
},
|
|
126694
|
+
// NOT safe to retry — see the module comment.
|
|
126695
|
+
step_started: {
|
|
126696
|
+
retryable: false,
|
|
126697
|
+
reason: "unconditional attempt increment → a retry double-counts attempts"
|
|
126698
|
+
},
|
|
126699
|
+
step_retrying: {
|
|
126700
|
+
retryable: false,
|
|
126701
|
+
reason: "no duplicate guard → a retry appends a second event row"
|
|
126702
|
+
},
|
|
126703
|
+
hook_received: {
|
|
126704
|
+
retryable: false,
|
|
126705
|
+
reason: "no server guard → a retry duplicates the row / re-delivers payload"
|
|
126706
|
+
},
|
|
126707
|
+
// Server-originated; the SDK never POSTs it.
|
|
126708
|
+
hook_conflict: {
|
|
126709
|
+
retryable: false,
|
|
126710
|
+
reason: "server-originated; never POSTed by the SDK"
|
|
126711
|
+
}
|
|
126712
|
+
};
|
|
126713
|
+
const MAX_EVENT_POST_RETRIES = 2;
|
|
126714
|
+
const EVENT_POST_RETRY_BASE_MS = 100;
|
|
126715
|
+
const EVENT_POST_RETRY_JITTER_MS = 50;
|
|
126716
|
+
const TRANSIENT_CODES = /* @__PURE__ */ new Set([
|
|
126717
|
+
"ECONNRESET",
|
|
126718
|
+
"ECONNREFUSED",
|
|
126719
|
+
"ENOTFOUND",
|
|
126720
|
+
"ENETDOWN",
|
|
126721
|
+
"ENETUNREACH",
|
|
126722
|
+
"EHOSTDOWN",
|
|
126723
|
+
"EHOSTUNREACH",
|
|
126724
|
+
"EPIPE",
|
|
126725
|
+
"ETIMEDOUT",
|
|
126726
|
+
"UND_ERR_SOCKET",
|
|
126727
|
+
"UND_ERR_REQ_RETRY",
|
|
126728
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
126729
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
126730
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
126731
|
+
// Names (undici/Node surface these on the error or its cause).
|
|
126732
|
+
// `TimeoutError` is our own per-request deadline (`AbortSignal.timeout` in
|
|
126733
|
+
// makeRequest) — a genuinely ambiguous failure worth retrying. We deliberately
|
|
126734
|
+
// do NOT include `AbortError`: that is how an external/caller-supplied
|
|
126735
|
+
// cancellation surfaces (makeRequest composes the caller's signal via
|
|
126736
|
+
// `AbortSignal.any`), and re-issuing a write the caller asked to cancel —
|
|
126737
|
+
// stalling the abort by the full backoff budget — would be wrong.
|
|
126738
|
+
"TimeoutError",
|
|
126739
|
+
"RequestRetryError"
|
|
126740
|
+
]);
|
|
126741
|
+
function collectErrorMarkers(err, depth = 0) {
|
|
126742
|
+
if (depth > 5 || err === null || typeof err !== "object")
|
|
126743
|
+
return [];
|
|
126744
|
+
const markers2 = [];
|
|
126745
|
+
const e = err;
|
|
126746
|
+
if (typeof e.code === "string")
|
|
126747
|
+
markers2.push(e.code);
|
|
126748
|
+
if (typeof e.name === "string")
|
|
126749
|
+
markers2.push(e.name);
|
|
126750
|
+
if (e.cause)
|
|
126751
|
+
markers2.push(...collectErrorMarkers(e.cause, depth + 1));
|
|
126752
|
+
return markers2;
|
|
126753
|
+
}
|
|
126754
|
+
function isRetryableEventPostError(err) {
|
|
126755
|
+
if (EntityConflictError.is(err) || RunExpiredError.is(err) || TooEarlyError.is(err) || ThrottleError.is(err)) {
|
|
126756
|
+
return false;
|
|
126757
|
+
}
|
|
126758
|
+
if (WorkflowWorldError.is(err)) {
|
|
126759
|
+
if (err.code === "PARSE_ERROR")
|
|
126760
|
+
return true;
|
|
126761
|
+
if (typeof err.status === "number") {
|
|
126762
|
+
return err.status >= 500 && err.status <= 599;
|
|
126763
|
+
}
|
|
126764
|
+
}
|
|
126765
|
+
return collectErrorMarkers(err).some((m2) => TRANSIENT_CODES.has(m2));
|
|
126766
|
+
}
|
|
126767
|
+
const sleep$1 = (ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2));
|
|
126768
|
+
const RETRY_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
126769
|
+
function logRetry(message2, fields) {
|
|
126770
|
+
if (!RETRY_DEBUG_ENABLED)
|
|
126771
|
+
return;
|
|
126772
|
+
const suffix = Object.entries(fields).map(([k2, v2]) => `${k2}=${v2}`).join(" ");
|
|
126773
|
+
console.debug(`[workflow:world-vercel:event-retry] ${message2} ${suffix}`);
|
|
126774
|
+
}
|
|
126775
|
+
function errorMarker(err) {
|
|
126776
|
+
if (WorkflowWorldError.is(err)) {
|
|
126777
|
+
return err.code ?? (err.status != null ? `status_${err.status}` : err.name);
|
|
126778
|
+
}
|
|
126779
|
+
return collectErrorMarkers(err)[0] ?? (err instanceof Error ? err.name : "unknown");
|
|
126780
|
+
}
|
|
126781
|
+
async function withEventPostRetry(fn2, eventType) {
|
|
126782
|
+
var _a3;
|
|
126783
|
+
const retryable = ((_a3 = EVENT_RETRY_ELIGIBILITY[eventType]) == null ? void 0 : _a3.retryable) ?? false;
|
|
126784
|
+
for (let attempt = 0; ; attempt++) {
|
|
126785
|
+
try {
|
|
126786
|
+
return await fn2();
|
|
126787
|
+
} catch (err) {
|
|
126788
|
+
const transient = retryable && isRetryableEventPostError(err);
|
|
126789
|
+
if (transient && attempt < MAX_EVENT_POST_RETRIES) {
|
|
126790
|
+
const backoff = EVENT_POST_RETRY_BASE_MS * 2 ** attempt + Math.floor(Math.random() * EVENT_POST_RETRY_JITTER_MS);
|
|
126791
|
+
logRetry("retrying event POST after transient failure", {
|
|
126792
|
+
eventType,
|
|
126793
|
+
attempt: attempt + 1,
|
|
126794
|
+
backoffMs: backoff,
|
|
126795
|
+
error: errorMarker(err)
|
|
126796
|
+
});
|
|
126797
|
+
await sleep$1(backoff);
|
|
126798
|
+
continue;
|
|
126799
|
+
}
|
|
126800
|
+
if (transient) {
|
|
126801
|
+
logRetry("exhausted in-process retries; surfacing for queue redelivery", {
|
|
126802
|
+
eventType,
|
|
126803
|
+
attempts: attempt + 1,
|
|
126804
|
+
error: errorMarker(err)
|
|
126805
|
+
});
|
|
126806
|
+
}
|
|
126807
|
+
throw err;
|
|
126808
|
+
}
|
|
126809
|
+
}
|
|
126810
|
+
}
|
|
126389
126811
|
const V4_FRAME_CONTENT_TYPE = "application/vnd.workflow.v4-frames";
|
|
126390
126812
|
function encodeFrame(meta2, body2) {
|
|
126391
126813
|
const metaBytes = new Uint8Array(encode(meta2));
|
|
@@ -126419,42 +126841,75 @@ async function* decodeFrames(source) {
|
|
|
126419
126841
|
buffer2 = buffer2.subarray(n);
|
|
126420
126842
|
return out;
|
|
126421
126843
|
};
|
|
126422
|
-
|
|
126423
|
-
|
|
126424
|
-
|
|
126425
|
-
|
|
126426
|
-
|
|
126427
|
-
|
|
126428
|
-
|
|
126429
|
-
|
|
126430
|
-
|
|
126431
|
-
|
|
126432
|
-
|
|
126433
|
-
|
|
126434
|
-
|
|
126435
|
-
|
|
126436
|
-
|
|
126437
|
-
if (!await refill(bodyLen)) {
|
|
126844
|
+
try {
|
|
126845
|
+
while (true) {
|
|
126846
|
+
if (!await refill(4))
|
|
126847
|
+
return;
|
|
126848
|
+
const metaLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
|
|
126849
|
+
take(4);
|
|
126850
|
+
if (!await refill(metaLen)) {
|
|
126851
|
+
throw new Error("decodeFrames: truncated meta block");
|
|
126852
|
+
}
|
|
126853
|
+
const meta2 = decode(take(metaLen));
|
|
126854
|
+
if (!await refill(4)) {
|
|
126855
|
+
throw new Error("decodeFrames: truncated body length");
|
|
126856
|
+
}
|
|
126857
|
+
const bodyLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
|
|
126858
|
+
take(4);
|
|
126859
|
+
if (bodyLen > 0 && !await refill(bodyLen)) {
|
|
126438
126860
|
throw new Error("decodeFrames: truncated body bytes");
|
|
126439
126861
|
}
|
|
126440
126862
|
yield { meta: meta2, body: buffer2.slice(0, bodyLen) };
|
|
126441
126863
|
take(bodyLen);
|
|
126442
|
-
|
|
126443
|
-
|
|
126864
|
+
if (meta2._end === 1)
|
|
126865
|
+
return;
|
|
126444
126866
|
}
|
|
126445
|
-
|
|
126446
|
-
|
|
126867
|
+
} finally {
|
|
126868
|
+
closeQuietly(() => {
|
|
126869
|
+
var _a3;
|
|
126870
|
+
return (_a3 = chunks.return) == null ? void 0 : _a3.call(chunks);
|
|
126871
|
+
});
|
|
126872
|
+
}
|
|
126873
|
+
}
|
|
126874
|
+
function closeQuietly(close) {
|
|
126875
|
+
try {
|
|
126876
|
+
void Promise.resolve(close()).catch(() => {
|
|
126877
|
+
});
|
|
126878
|
+
} catch {
|
|
126447
126879
|
}
|
|
126448
126880
|
}
|
|
126449
126881
|
async function* readerToIterator(reader) {
|
|
126450
|
-
|
|
126451
|
-
|
|
126452
|
-
|
|
126453
|
-
|
|
126454
|
-
|
|
126455
|
-
|
|
126882
|
+
try {
|
|
126883
|
+
while (true) {
|
|
126884
|
+
const { done, value } = await reader.read();
|
|
126885
|
+
if (done)
|
|
126886
|
+
return;
|
|
126887
|
+
if (value)
|
|
126888
|
+
yield value;
|
|
126889
|
+
}
|
|
126890
|
+
} finally {
|
|
126891
|
+
closeQuietly(() => reader.cancel());
|
|
126456
126892
|
}
|
|
126457
126893
|
}
|
|
126894
|
+
async function fetchV4(url2, init2, config2, opName) {
|
|
126895
|
+
return instrumentedFetch({
|
|
126896
|
+
method: init2.method,
|
|
126897
|
+
url: url2,
|
|
126898
|
+
headers: init2.headers,
|
|
126899
|
+
body: init2.body,
|
|
126900
|
+
dispatcher: getEventsDispatcher(config2),
|
|
126901
|
+
timeoutMs: null,
|
|
126902
|
+
logLabel: opName,
|
|
126903
|
+
buildError: async (response2) => errorFromV4Response(response2.status, headersToRecord(response2.headers), await response2.text(), opName, url2)
|
|
126904
|
+
});
|
|
126905
|
+
}
|
|
126906
|
+
function headersToRecord(headers2) {
|
|
126907
|
+
const out = {};
|
|
126908
|
+
headers2.forEach((value, key) => {
|
|
126909
|
+
out[key] = value;
|
|
126910
|
+
});
|
|
126911
|
+
return out;
|
|
126912
|
+
}
|
|
126458
126913
|
const V4_RESPONSE_HEADERS = {
|
|
126459
126914
|
eventId: "x-wf-event-id",
|
|
126460
126915
|
runId: "x-wf-run-id",
|
|
@@ -126500,9 +126955,12 @@ function buildPostFrameMeta(input) {
|
|
|
126500
126955
|
if (input.executionContext !== void 0) {
|
|
126501
126956
|
meta2.executionContext = input.executionContext;
|
|
126502
126957
|
}
|
|
126958
|
+
if (input.stateUpdatedAt !== void 0) {
|
|
126959
|
+
meta2.stateUpdatedAt = input.stateUpdatedAt;
|
|
126960
|
+
}
|
|
126503
126961
|
return meta2;
|
|
126504
126962
|
}
|
|
126505
|
-
function
|
|
126963
|
+
function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url2) {
|
|
126506
126964
|
let message2 = `v4 ${opName} failed: HTTP ${statusCode}`;
|
|
126507
126965
|
let code2;
|
|
126508
126966
|
try {
|
|
@@ -126515,35 +126973,12 @@ function throwForErrorResponse(statusCode, responseHeaders, errorBody, opName, u
|
|
|
126515
126973
|
if (errorBody)
|
|
126516
126974
|
message2 += ` ${errorBody}`;
|
|
126517
126975
|
}
|
|
126518
|
-
|
|
126519
|
-
|
|
126520
|
-
|
|
126521
|
-
const parsed = parseInt(retryAfterHeader, 10);
|
|
126522
|
-
if (!Number.isNaN(parsed))
|
|
126523
|
-
retryAfter = parsed;
|
|
126524
|
-
}
|
|
126525
|
-
if (statusCode === 409)
|
|
126526
|
-
throw new EntityConflictError(message2);
|
|
126527
|
-
if (statusCode === 410)
|
|
126528
|
-
throw new RunExpiredError(message2);
|
|
126529
|
-
if (statusCode === 425)
|
|
126530
|
-
throw new TooEarlyError(message2, { retryAfter });
|
|
126531
|
-
if (statusCode === 429) {
|
|
126532
|
-
if (readHeader(responseHeaders, "x-vercel-mitigated") === "challenge") {
|
|
126533
|
-
throw new WorkflowWorldError(`${message2} (x-vercel-mitigated=challenge)`, {
|
|
126534
|
-
status: statusCode,
|
|
126535
|
-
code: "TRANSPORT",
|
|
126536
|
-
url: url2,
|
|
126537
|
-
retryAfter
|
|
126538
|
-
});
|
|
126539
|
-
}
|
|
126540
|
-
throw new ThrottleError(message2, { retryAfter });
|
|
126541
|
-
}
|
|
126542
|
-
throw new WorkflowWorldError(message2, {
|
|
126543
|
-
status: statusCode,
|
|
126976
|
+
const retryAfter = parseRetryAfter(readHeader(responseHeaders, "retry-after"));
|
|
126977
|
+
return errorForResponse(statusCode, message2, {
|
|
126978
|
+
retryAfter,
|
|
126544
126979
|
code: code2,
|
|
126545
126980
|
url: url2,
|
|
126546
|
-
|
|
126981
|
+
mitigated: readHeader(responseHeaders, "x-vercel-mitigated")
|
|
126547
126982
|
});
|
|
126548
126983
|
}
|
|
126549
126984
|
async function createWorkflowRunEventV4(input, config2) {
|
|
@@ -126552,26 +126987,14 @@ async function createWorkflowRunEventV4(input, config2) {
|
|
|
126552
126987
|
headers2.set("Content-Type", "application/octet-stream");
|
|
126553
126988
|
const frame2 = encodeFrame(buildPostFrameMeta(input), input.payload ?? new Uint8Array(0));
|
|
126554
126989
|
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(input.runId)}/events/${encodeURIComponent(input.eventType)}`;
|
|
126555
|
-
const response2 = await
|
|
126556
|
-
|
|
126557
|
-
|
|
126558
|
-
|
|
126559
|
-
// getDispatcher() is typed `unknown` (undici's Dispatcher type is
|
|
126560
|
-
// version-specific across @types/node majors); cast to the undici
|
|
126561
|
-
// Dispatcher this module's own `request` expects.
|
|
126562
|
-
dispatcher: getDispatcher(config2)
|
|
126563
|
-
});
|
|
126564
|
-
if (response2.statusCode < 200 || response2.statusCode >= 300) {
|
|
126565
|
-
const errorBody = await response2.body.text();
|
|
126566
|
-
throwForErrorResponse(response2.statusCode, response2.headers, errorBody, "createEvent", url2);
|
|
126567
|
-
}
|
|
126568
|
-
const eventId = response2.headers[V4_RESPONSE_HEADERS.eventId];
|
|
126569
|
-
const runId = response2.headers[V4_RESPONSE_HEADERS.runId];
|
|
126570
|
-
const createdAt = response2.headers[V4_RESPONSE_HEADERS.createdAt];
|
|
126990
|
+
const response2 = await fetchV4(url2, { method: "POST", headers: headers2, body: frame2 }, config2, "createEvent");
|
|
126991
|
+
const eventId = response2.headers.get(V4_RESPONSE_HEADERS.eventId);
|
|
126992
|
+
const runId = response2.headers.get(V4_RESPONSE_HEADERS.runId);
|
|
126993
|
+
const createdAt = response2.headers.get(V4_RESPONSE_HEADERS.createdAt);
|
|
126571
126994
|
if (typeof eventId !== "string" || typeof runId !== "string" || typeof createdAt !== "string") {
|
|
126572
126995
|
throw new Error("v4 createEvent: response missing required x-wf-* headers");
|
|
126573
126996
|
}
|
|
126574
|
-
const bodyBytes = new Uint8Array(await response2.
|
|
126997
|
+
const bodyBytes = new Uint8Array(await response2.arrayBuffer());
|
|
126575
126998
|
const body2 = bodyBytes.byteLength > 0 ? decode(bodyBytes) : {};
|
|
126576
126999
|
return { eventId, runId, createdAt, body: body2 };
|
|
126577
127000
|
}
|
|
@@ -126586,19 +127009,8 @@ function readHeader(responseHeaders, name2) {
|
|
|
126586
127009
|
async function getEventV4(runId, eventId, config2) {
|
|
126587
127010
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
126588
127011
|
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}`;
|
|
126589
|
-
const response2 = await
|
|
126590
|
-
|
|
126591
|
-
headers: Object.fromEntries(headers2.entries()),
|
|
126592
|
-
// getDispatcher() is typed `unknown` (undici's Dispatcher type is
|
|
126593
|
-
// version-specific across @types/node majors); cast to the undici
|
|
126594
|
-
// Dispatcher this module's own `request` expects.
|
|
126595
|
-
dispatcher: getDispatcher(config2)
|
|
126596
|
-
});
|
|
126597
|
-
if (response2.statusCode < 200 || response2.statusCode >= 300) {
|
|
126598
|
-
const errorBody = await response2.body.text();
|
|
126599
|
-
throwForErrorResponse(response2.statusCode, response2.headers, errorBody, "getEvent", url2);
|
|
126600
|
-
}
|
|
126601
|
-
const contentType = readHeader(response2.headers, "content-type");
|
|
127012
|
+
const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, "getEvent");
|
|
127013
|
+
const contentType = response2.headers.get("content-type");
|
|
126602
127014
|
if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
|
|
126603
127015
|
throw new Error(`v4 getEvent: expected ${V4_FRAME_CONTENT_TYPE}, got ${contentType ?? "(none)"}`);
|
|
126604
127016
|
}
|
|
@@ -126609,19 +127021,8 @@ async function getEventV4(runId, eventId, config2) {
|
|
|
126609
127021
|
throw new Error(`v4 getEvent: empty frame stream for ${eventId}`);
|
|
126610
127022
|
}
|
|
126611
127023
|
async function consumeListFrameStream(url2, headers2, config2, opName) {
|
|
126612
|
-
const response2 = await
|
|
126613
|
-
|
|
126614
|
-
headers: Object.fromEntries(headers2.entries()),
|
|
126615
|
-
// getDispatcher() is typed `unknown` (undici's Dispatcher type is
|
|
126616
|
-
// version-specific across @types/node majors); cast to the undici
|
|
126617
|
-
// Dispatcher this module's own `request` expects.
|
|
126618
|
-
dispatcher: getDispatcher(config2)
|
|
126619
|
-
});
|
|
126620
|
-
if (response2.statusCode < 200 || response2.statusCode >= 300) {
|
|
126621
|
-
const errorBody = await response2.body.text();
|
|
126622
|
-
throwForErrorResponse(response2.statusCode, response2.headers, errorBody, opName, url2);
|
|
126623
|
-
}
|
|
126624
|
-
const contentType = readHeader(response2.headers, "content-type");
|
|
127024
|
+
const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, opName);
|
|
127025
|
+
const contentType = response2.headers.get("content-type");
|
|
126625
127026
|
if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
|
|
126626
127027
|
throw new Error(`v4 ${opName}: expected ${V4_FRAME_CONTENT_TYPE}, got ${contentType ?? "(none)"}`);
|
|
126627
127028
|
}
|
|
@@ -127066,7 +127467,7 @@ async function getWorkflowRunEvents(params, config2) {
|
|
|
127066
127467
|
}
|
|
127067
127468
|
async function createWorkflowRunEvent(id2, data, params, config2) {
|
|
127068
127469
|
try {
|
|
127069
|
-
return await createWorkflowRunEventInner(id2, data, params, config2);
|
|
127470
|
+
return await withEventPostRetry(() => createWorkflowRunEventInner(id2, data, params, config2), data.eventType);
|
|
127070
127471
|
} catch (err) {
|
|
127071
127472
|
if (hookEventsRequiringExistence.has(data.eventType) && WorkflowWorldError.is(err) && err.status === 404 && data.correlationId) {
|
|
127072
127473
|
throw new HookNotFoundError(data.correlationId);
|
|
@@ -127113,6 +127514,7 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
127113
127514
|
specVersion: data.specVersion ?? 2,
|
|
127114
127515
|
...data.correlationId ? { correlationId: data.correlationId } : {},
|
|
127115
127516
|
...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
|
|
127517
|
+
...(params == null ? void 0 : params.stateUpdatedAt) !== void 0 ? { stateUpdatedAt: params.stateUpdatedAt } : {},
|
|
127116
127518
|
occurredAt: (params == null ? void 0 : params.occurredAt) ?? /* @__PURE__ */ new Date(),
|
|
127117
127519
|
remoteRefBehavior,
|
|
127118
127520
|
payload,
|
|
@@ -127128,7 +127530,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
127128
127530
|
wait: body2.wait,
|
|
127129
127531
|
events: body2.events ? body2.events.map(coerceEventDates) : void 0,
|
|
127130
127532
|
cursor: body2.cursor ?? void 0,
|
|
127131
|
-
hasMore: body2.hasMore
|
|
127533
|
+
hasMore: body2.hasMore,
|
|
127534
|
+
// Server-supplied per-run event ceiling; absent from older servers.
|
|
127535
|
+
...typeof body2.maxEvents === "number" ? { maxEvents: body2.maxEvents } : {}
|
|
127132
127536
|
};
|
|
127133
127537
|
}
|
|
127134
127538
|
function filterHookData(hook, resolveData) {
|
|
@@ -127242,30 +127646,28 @@ function getStreamMutationTimeoutMs() {
|
|
|
127242
127646
|
}
|
|
127243
127647
|
return DEFAULT_STREAM_MUTATION_TIMEOUT_MS;
|
|
127244
127648
|
}
|
|
127245
|
-
async function fetchStreamMutation(url2, init2, operation) {
|
|
127246
|
-
const
|
|
127247
|
-
|
|
127248
|
-
|
|
127249
|
-
|
|
127250
|
-
|
|
127251
|
-
|
|
127252
|
-
|
|
127253
|
-
|
|
127254
|
-
|
|
127255
|
-
|
|
127256
|
-
|
|
127257
|
-
|
|
127258
|
-
|
|
127259
|
-
}
|
|
127649
|
+
async function fetchStreamMutation(url2, init2, operation, config2) {
|
|
127650
|
+
const response2 = await instrumentedFetch({
|
|
127651
|
+
method: init2.method,
|
|
127652
|
+
url: url2.toString(),
|
|
127653
|
+
headers: init2.headers,
|
|
127654
|
+
body: init2.body,
|
|
127655
|
+
// Stream mutations go through the dedicated H2 stream dispatchers rather
|
|
127656
|
+
// than the global agent — see the note at the top of this file. Close is
|
|
127657
|
+
// idempotent (unlike chunk appends), so it gets the dispatcher that
|
|
127658
|
+
// retries 5xx, which the server's close-barrier protocol depends on.
|
|
127659
|
+
dispatcher: operation === "close" ? getStreamCloseDispatcher(config2) : getStreamDispatcher(config2),
|
|
127660
|
+
timeoutMs: getStreamMutationTimeoutMs(),
|
|
127661
|
+
logLabel: url2.pathname,
|
|
127662
|
+
buildError: async (res) => createStreamRequestError(operation, url2, res, await res.text())
|
|
127663
|
+
});
|
|
127664
|
+
await response2.text();
|
|
127260
127665
|
}
|
|
127261
127666
|
function createStreamRequestError(operation, url2, response2, text2) {
|
|
127262
|
-
const context = [
|
|
127263
|
-
|
|
127264
|
-
|
|
127265
|
-
|
|
127266
|
-
context.push(`${header}=${value}`);
|
|
127267
|
-
}
|
|
127268
|
-
}
|
|
127667
|
+
const context = [
|
|
127668
|
+
`PUT ${url2.origin}${url2.pathname}`,
|
|
127669
|
+
...getVercelDiagnostics(response2.headers)
|
|
127670
|
+
];
|
|
127269
127671
|
return new Error(`Stream ${operation} failed: HTTP ${response2.status} (${context.join("; ")}): ${text2}`);
|
|
127270
127672
|
}
|
|
127271
127673
|
function encodeMultiChunks(chunks) {
|
|
@@ -127307,15 +127709,11 @@ function createStreamer(config2) {
|
|
|
127307
127709
|
const resolvedRunId = await runId;
|
|
127308
127710
|
const httpConfig = await getHttpConfig(config2);
|
|
127309
127711
|
const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
|
|
127310
|
-
|
|
127712
|
+
await fetchStreamMutation(url2, {
|
|
127311
127713
|
method: "PUT",
|
|
127312
127714
|
body: chunk,
|
|
127313
127715
|
headers: httpConfig.headers
|
|
127314
|
-
}, "write");
|
|
127315
|
-
const text2 = await response2.text();
|
|
127316
|
-
if (!response2.ok) {
|
|
127317
|
-
throw createStreamRequestError("write", url2, response2, text2);
|
|
127318
|
-
}
|
|
127716
|
+
}, "write", config2);
|
|
127319
127717
|
},
|
|
127320
127718
|
async writeToStreamMulti(name2, runId, chunks) {
|
|
127321
127719
|
if (chunks.length === 0)
|
|
@@ -127327,15 +127725,11 @@ function createStreamer(config2) {
|
|
|
127327
127725
|
const batch = chunks.slice(i, i + MAX_CHUNKS_PER_REQUEST);
|
|
127328
127726
|
const body2 = encodeMultiChunks(batch);
|
|
127329
127727
|
const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
|
|
127330
|
-
|
|
127728
|
+
await fetchStreamMutation(url2, {
|
|
127331
127729
|
method: "PUT",
|
|
127332
127730
|
body: body2,
|
|
127333
127731
|
headers: httpConfig.headers
|
|
127334
|
-
}, "write");
|
|
127335
|
-
const text2 = await response2.text();
|
|
127336
|
-
if (!response2.ok) {
|
|
127337
|
-
throw createStreamRequestError("write", url2, response2, text2);
|
|
127338
|
-
}
|
|
127732
|
+
}, "write", config2);
|
|
127339
127733
|
}
|
|
127340
127734
|
},
|
|
127341
127735
|
async closeStream(name2, runId) {
|
|
@@ -127343,14 +127737,10 @@ function createStreamer(config2) {
|
|
|
127343
127737
|
const httpConfig = await getHttpConfig(config2);
|
|
127344
127738
|
httpConfig.headers.set("X-Stream-Done", "true");
|
|
127345
127739
|
const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
|
|
127346
|
-
|
|
127740
|
+
await fetchStreamMutation(url2, {
|
|
127347
127741
|
method: "PUT",
|
|
127348
127742
|
headers: httpConfig.headers
|
|
127349
|
-
}, "close");
|
|
127350
|
-
const text2 = await response2.text();
|
|
127351
|
-
if (!response2.ok) {
|
|
127352
|
-
throw createStreamRequestError("close", url2, response2, text2);
|
|
127353
|
-
}
|
|
127743
|
+
}, "close", config2);
|
|
127354
127744
|
},
|
|
127355
127745
|
async readFromStream(name2, startIndex) {
|
|
127356
127746
|
const httpConfig = await getHttpConfig(config2);
|
|
@@ -127359,13 +127749,16 @@ function createStreamer(config2) {
|
|
|
127359
127749
|
url2.searchParams.set("startIndex", String(startIndex));
|
|
127360
127750
|
}
|
|
127361
127751
|
const abortController = new AbortController();
|
|
127362
|
-
const response2 = await
|
|
127752
|
+
const response2 = await instrumentedFetch({
|
|
127753
|
+
method: "GET",
|
|
127754
|
+
url: url2.toString(),
|
|
127363
127755
|
headers: httpConfig.headers,
|
|
127364
|
-
|
|
127756
|
+
dispatcher: void 0,
|
|
127757
|
+
timeoutMs: null,
|
|
127758
|
+
signal: abortController.signal,
|
|
127759
|
+
logLabel: url2.pathname,
|
|
127760
|
+
buildError: (res) => new Error(`Failed to fetch stream: ${res.status}`)
|
|
127365
127761
|
});
|
|
127366
|
-
if (!response2.ok) {
|
|
127367
|
-
throw new Error(`Failed to fetch stream: ${response2.status}`);
|
|
127368
|
-
}
|
|
127369
127762
|
if (!response2.body) {
|
|
127370
127763
|
throw new Error("No response body for stream");
|
|
127371
127764
|
}
|
|
@@ -127421,12 +127814,15 @@ function createStreamer(config2) {
|
|
|
127421
127814
|
async listStreamsByRunId(runId) {
|
|
127422
127815
|
const httpConfig = await getHttpConfig(config2);
|
|
127423
127816
|
const url2 = new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/streams`);
|
|
127424
|
-
const response2 = await
|
|
127425
|
-
|
|
127817
|
+
const response2 = await instrumentedFetch({
|
|
127818
|
+
method: "GET",
|
|
127819
|
+
url: url2.toString(),
|
|
127820
|
+
headers: httpConfig.headers,
|
|
127821
|
+
dispatcher: void 0,
|
|
127822
|
+
timeoutMs: null,
|
|
127823
|
+
logLabel: url2.pathname,
|
|
127824
|
+
buildError: (res) => new Error(`Failed to list streams: ${res.status}`)
|
|
127426
127825
|
});
|
|
127427
|
-
if (!response2.ok) {
|
|
127428
|
-
throw new Error(`Failed to list streams: ${response2.status}`);
|
|
127429
|
-
}
|
|
127430
127826
|
return await response2.json();
|
|
127431
127827
|
}
|
|
127432
127828
|
};
|
|
@@ -131953,7 +132349,7 @@ function getRunCapabilities(workflowCoreVersion) {
|
|
|
131953
132349
|
return result;
|
|
131954
132350
|
}
|
|
131955
132351
|
function waitUntil(promise2) {
|
|
131956
|
-
void import("./index-
|
|
132352
|
+
void import("./index-CMfOrLiJ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
|
|
131957
132353
|
waitUntil2(promise2);
|
|
131958
132354
|
});
|
|
131959
132355
|
}
|