@run402/sdk 4.148.4 → 4.148.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/namespaces/deploy.d.ts.map +1 -1
- package/dist/namespaces/deploy.js +74 -20
- package/dist/namespaces/deploy.js.map +1 -1
- package/dist/namespaces/deploy.types.d.ts +9 -0
- package/dist/namespaces/deploy.types.d.ts.map +1 -1
- package/dist/node/actions-node.d.ts.map +1 -1
- package/dist/node/actions-node.js +59 -2
- package/dist/node/actions-node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/namespaces/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAwB3C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAQtB,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EAIvB,sBAAsB,EACtB,oBAAoB,EAUpB,iBAAiB,EAGjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAGlB,YAAY,EAEb,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/namespaces/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAwB3C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAQtB,WAAW,EACX,oBAAoB,EA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ETRY_DEFAULT_MAX_RETRIES = 2;
|
|
|
40
40
|
const APPLY_RETRY_BASE_DELAY_MS = 250;
|
|
41
41
|
const APPLY_RETRY_MAX_DELAY_MS = 2_000;
|
|
42
42
|
const APPLY_RETRY_JITTER_MS = 100;
|
|
43
|
-
const CONTENT_COMMIT_MAX_ATTEMPTS = 3;
|
|
44
43
|
const DEPLOY_COMMIT_MAX_ATTEMPTS = 3;
|
|
45
44
|
const DEPLOY_COMMIT_RETRY_BASE_DELAY_MS = 1_000;
|
|
46
|
-
|
|
45
|
+
/** A content commit the gateway answered 202 is read back on this schedule. */
|
|
46
|
+
const CONTENT_COMMIT_POLL_INITIAL_MS = 1_000;
|
|
47
|
+
const CONTENT_COMMIT_POLL_MAX_MS = 10_000;
|
|
48
|
+
const CONTENT_COMMIT_POLL_TIMEOUT_MS = 60 * 60 * 1000;
|
|
49
|
+
/** The commit answers within 20 s (200 when done, else 202 with a poll) instead
|
|
50
|
+
* of holding the request for as long as a large promote takes (RFC 7240). */
|
|
51
|
+
const CONTENT_COMMIT_PREFER = "respond-async, wait=20";
|
|
47
52
|
const URL_REFRESH_AT_MS = 50 * 60 * 1000;
|
|
48
53
|
const SECRET_KEY_RE = /^[A-Z_][A-Z0-9_]{0,127}$/;
|
|
49
54
|
const APPLY_SAFE_RETRY_CODES = new Set([
|
|
@@ -1874,7 +1879,7 @@ async function uploadMissing(client, projectId, presence, byteReaders, emit) {
|
|
|
1874
1879
|
// Plan-level finalize — marks the plan committed in the deploy_plans
|
|
1875
1880
|
// table. Per-session promotion to CAS already happened in the loop
|
|
1876
1881
|
// above; this call is the plan-level idempotency anchor.
|
|
1877
|
-
await
|
|
1882
|
+
await commitContentPlan(client, planRes.plan_id, headers);
|
|
1878
1883
|
}
|
|
1879
1884
|
async function uploadCoreContent(client, projectId, byteReaders, emit) {
|
|
1880
1885
|
const entries = [...byteReaders.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
@@ -1904,27 +1909,67 @@ async function uploadCoreContent(client, projectId, byteReaders, emit) {
|
|
|
1904
1909
|
}
|
|
1905
1910
|
}
|
|
1906
1911
|
/**
|
|
1907
|
-
* Finalize a content plan
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1912
|
+
* Finalize a content plan by following the gateway's answer. The gateway runs
|
|
1913
|
+
* one commit per plan, detached from the request, and with
|
|
1914
|
+
* `Prefer: respond-async, wait=20` answers its state within 20 s: 200
|
|
1915
|
+
* is done; 202 `committing` is followed by reading the plan (its `poll` next
|
|
1916
|
+
* action) until the commit is terminal; a read that says `pending` (the commit
|
|
1917
|
+
* never reached the gateway) is followed by the commit it names. A 502/503/504
|
|
1918
|
+
* or a dropped connection on the commit becomes a read of the plan, never a
|
|
1919
|
+
* second commit. `failed` and `expired` throw with the plan id.
|
|
1912
1920
|
*/
|
|
1913
|
-
async function
|
|
1914
|
-
|
|
1921
|
+
async function commitContentPlan(client, planId, headers) {
|
|
1922
|
+
const planPath = `/content/v1/plans/${encodeURIComponent(planId)}`;
|
|
1923
|
+
const postCommit = async () => {
|
|
1915
1924
|
try {
|
|
1916
|
-
await client.request(
|
|
1917
|
-
|
|
1925
|
+
return await client.request(`${planPath}/commit`, {
|
|
1926
|
+
method: "POST",
|
|
1927
|
+
headers: { ...headers, Prefer: CONTENT_COMMIT_PREFER },
|
|
1928
|
+
body: {},
|
|
1929
|
+
context: "committing content upload",
|
|
1930
|
+
});
|
|
1918
1931
|
}
|
|
1919
1932
|
catch (err) {
|
|
1920
|
-
if (
|
|
1921
|
-
return;
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1933
|
+
if (isTransientGatewayFailure(err))
|
|
1934
|
+
return null;
|
|
1935
|
+
throw err;
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
const deadline = Date.now() + CONTENT_COMMIT_POLL_TIMEOUT_MS;
|
|
1939
|
+
let delay = CONTENT_COMMIT_POLL_INITIAL_MS;
|
|
1940
|
+
let state = await postCommit();
|
|
1941
|
+
for (;;) {
|
|
1942
|
+
const status = state?.status;
|
|
1943
|
+
if (state && status !== "committing" && status !== "pending") {
|
|
1944
|
+
if (status === "failed" || status === "expired")
|
|
1945
|
+
throw contentCommitStateError(planId, state);
|
|
1946
|
+
return;
|
|
1925
1947
|
}
|
|
1948
|
+
if (Date.now() >= deadline) {
|
|
1949
|
+
throw new Run402DeployError(`Content commit for plan ${planId} was still running after ${CONTENT_COMMIT_POLL_TIMEOUT_MS / 60_000} minutes; read GET ${planPath} for its state`, { code: "CONTENT_UPLOAD_FAILED", phase: "upload", retryable: true, planId, context: "committing content upload" });
|
|
1950
|
+
}
|
|
1951
|
+
if (status === "pending") {
|
|
1952
|
+
state = await postCommit();
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
await sleep(delay);
|
|
1956
|
+
delay = Math.min(delay * 2, CONTENT_COMMIT_POLL_MAX_MS);
|
|
1957
|
+
state = await requestWithTransientRetry(() => client.request(planPath, { method: "GET", headers, context: "reading the content commit" }));
|
|
1926
1958
|
}
|
|
1927
1959
|
}
|
|
1960
|
+
function contentCommitStateError(planId, state) {
|
|
1961
|
+
const reason = state.status === "expired"
|
|
1962
|
+
? "the plan expired before it was committed"
|
|
1963
|
+
: `${state.error?.code ?? "failed"}: ${state.error?.message ?? "the commit failed"}`;
|
|
1964
|
+
return new Run402DeployError(`Content commit for plan ${planId} failed (${reason})`, {
|
|
1965
|
+
code: "CONTENT_UPLOAD_FAILED",
|
|
1966
|
+
phase: "upload",
|
|
1967
|
+
retryable: state.status === "failed" && state.error?.retryable === true,
|
|
1968
|
+
planId,
|
|
1969
|
+
body: state,
|
|
1970
|
+
context: "committing content upload",
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1928
1973
|
/** Repeat a read or an idempotent request lost to a 502/503/504 or a dropped connection. */
|
|
1929
1974
|
async function requestWithTransientRetry(send) {
|
|
1930
1975
|
for (let attempt = 1;; attempt++) {
|
|
@@ -2099,7 +2144,8 @@ async function pollUntilReady(client, commit, diff, warnings, emit, projectId, s
|
|
|
2099
2144
|
const initialSnapshot = await client.request(`/apply/v1/operations/${encodeURIComponent(commit.operation_id)}`, { headers: opHeaders, context: "fetching deploy operation" });
|
|
2100
2145
|
// A deferred commit (schema_settling / activation_pending) already said
|
|
2101
2146
|
// what happened to its pre-migration snapshot and which warnings it raised;
|
|
2102
|
-
// the
|
|
2147
|
+
// they ride across the poll for a gateway whose operation snapshot does not
|
|
2148
|
+
// repeat them. A `running` commit says neither: the snapshot does.
|
|
2103
2149
|
return await pollSnapshotUntilReady(client, initialSnapshot, diff, mergeWarningsByCode(warnings, commit.warnings), emit, projectId, sliceKinds, commitSnapshotOutcome(commit));
|
|
2104
2150
|
}
|
|
2105
2151
|
/** Later warnings replace earlier ones with the same code (plan → commit → snapshot). */
|
|
@@ -2115,6 +2161,14 @@ function commitSnapshotOutcome(commit) {
|
|
|
2115
2161
|
...(commit.snapshot_skipped_reason ? { snapshot_skipped_reason: commit.snapshot_skipped_reason } : {}),
|
|
2116
2162
|
};
|
|
2117
2163
|
}
|
|
2164
|
+
/**
|
|
2165
|
+
* The operation snapshot's own snapshot outcome when it states one (the
|
|
2166
|
+
* gateway's record of the commit), else the one carried from the commit.
|
|
2167
|
+
*/
|
|
2168
|
+
function preferSnapshotOutcome(snapshot, carried) {
|
|
2169
|
+
const own = commitSnapshotOutcome(snapshot);
|
|
2170
|
+
return own.restore_point || own.snapshot_skipped_reason ? own : carried;
|
|
2171
|
+
}
|
|
2118
2172
|
async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, projectId, sliceKinds = [], snapshotOutcome = {}) {
|
|
2119
2173
|
// Helper to spread slice_kinds onto every commit.phase / ready emit so
|
|
2120
2174
|
// agents grouping per-slice telemetry don't need to track the apply's
|
|
@@ -2207,7 +2261,7 @@ async function pollSnapshotUntilReady(client, initial, diff, warnings, emit, pro
|
|
|
2207
2261
|
urls: snapshot.urls,
|
|
2208
2262
|
diff,
|
|
2209
2263
|
warnings: mergeWarningsByCode(warnings, snapshot.warnings),
|
|
2210
|
-
...snapshotOutcome,
|
|
2264
|
+
...preferSnapshotOutcome(snapshot, snapshotOutcome),
|
|
2211
2265
|
...(snapshot.subdomain_bindings ? { subdomain_bindings: snapshot.subdomain_bindings } : {}),
|
|
2212
2266
|
...(snapshot.static_continuity ? { static_continuity: snapshot.static_continuity } : {}),
|
|
2213
2267
|
...(snapshot.edge ? { edge: snapshot.edge } : {}),
|
|
@@ -4418,7 +4472,7 @@ async function uploadInlineCas(client, projectId, bytes, contentType) {
|
|
|
4418
4472
|
await uploadOne(client.fetch, session, bytes);
|
|
4419
4473
|
// v1.48 unified-apply: per-session /storage/v1/uploads/:id/complete is
|
|
4420
4474
|
// gone (404). The plan-level commit below promotes the session to CAS.
|
|
4421
|
-
await
|
|
4475
|
+
await commitContentPlan(client, planRes.plan_id, headers);
|
|
4422
4476
|
}
|
|
4423
4477
|
return { sha256, size: bytes.byteLength, contentType };
|
|
4424
4478
|
}
|