@keystrokehq/cli 0.1.155 → 0.1.156

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/index.mjs CHANGED
@@ -40,7 +40,7 @@ process.emitWarning = ((warning, ...args) => {
40
40
  if ((type === "ExperimentalWarning" || /ExperimentalWarning/i.test(type)) && /SQLite/i.test(message)) return;
41
41
  return Reflect.apply(originalEmitWarning, process, [warning, ...args]);
42
42
  });
43
- const { runCli } = await import("./program-Cb_jAhs0.mjs");
43
+ const { runCli } = await import("./program-CH1W0mPS.mjs");
44
44
  await runCli(process.argv);
45
45
  //#endregion
46
46
  export {};
@@ -11304,6 +11304,11 @@ const DEPLOY_TIMEOUT_MS = 12e4;
11304
11304
  const DEPLOY_LEASE_HEARTBEAT_MS = 3e4;
11305
11305
  const ARTIFACT_STORAGE_NETWORK_MESSAGE = "Could not reach artifact storage. Check your network/DNS and retry; corporate proxies or DNS policies sometimes block storage hosts.";
11306
11306
  const NON_INTERACTIVE_CONFIRM_HINT = "Pass --accept-impact to accept the current filtered deploy impact, or run interactively in a TTY.";
11307
+ /** Platform complete mapped a missing CAS blob after upload (often Tigris read lag). */
11308
+ /** @internal Exported for unit tests. */
11309
+ function isMissingModuleBlobCompleteError(error) {
11310
+ return error instanceof PlatformError && error.status === 400 && /Missing or incomplete module blob/i.test(error.message);
11311
+ }
11307
11312
  function asExpectedAuthoringOrNetworkError(error) {
11308
11313
  if (!(error instanceof Error)) return error;
11309
11314
  if (error instanceof PlatformError) {
@@ -11633,30 +11638,42 @@ async function runManagedDeploy(client, config, options) {
11633
11638
  if (verbose) process.stdout.write(` build: ${buildMs}ms\n`);
11634
11639
  assertLease();
11635
11640
  if (!verbose) process.stdout.write("Uploading…\n");
11636
- const uploadStarted = Date.now();
11637
- const renewed = await client.projectGit.renewDeployUpload(options.projectId, {
11638
- artifactId: prepared.artifact.id,
11639
- blobs: built.blobs
11640
- });
11641
11641
  const bytesByHash = new Map(built.modules.map((mod) => [mod.hash, mod.bytes]));
11642
- await Promise.all(renewed.uploads.map(async (upload) => {
11643
- const body = bytesByHash.get(upload.hash);
11644
- if (!body) throw new Error(`Missing bytes for module blob ${upload.hash}`);
11645
- const uploadResponse = await fetch(upload.url, {
11646
- method: "PUT",
11647
- body,
11648
- headers: { "Content-Type": "application/octet-stream" }
11642
+ const uploadAndComplete = async () => {
11643
+ const uploadStarted = Date.now();
11644
+ const renewed = await client.projectGit.renewDeployUpload(options.projectId, {
11645
+ artifactId: prepared.artifact.id,
11646
+ blobs: built.blobs
11649
11647
  });
11650
- if (!uploadResponse.ok) throw new Error(`Module upload failed (${uploadResponse.status}) for ${upload.hash}`);
11651
- }));
11652
- phase("upload", uploadStarted);
11653
- assertLease();
11654
- const completeStarted = Date.now();
11655
- const completed = await client.projectGit.completeDeployArtifact(options.projectId, {
11656
- artifactId: prepared.artifact.id,
11657
- index: built.index
11658
- });
11659
- phase("complete", completeStarted);
11648
+ await Promise.all(renewed.uploads.map(async (upload) => {
11649
+ const body = bytesByHash.get(upload.hash);
11650
+ if (!body) throw new Error(`Missing bytes for module blob ${upload.hash}`);
11651
+ const uploadResponse = await fetch(upload.url, {
11652
+ method: "PUT",
11653
+ body,
11654
+ headers: { "Content-Type": "application/octet-stream" }
11655
+ });
11656
+ if (!uploadResponse.ok) throw new Error(`Module upload failed (${uploadResponse.status}) for ${upload.hash}`);
11657
+ }));
11658
+ phase("upload", uploadStarted);
11659
+ assertLease();
11660
+ const completeStarted = Date.now();
11661
+ const completed = await client.projectGit.completeDeployArtifact(options.projectId, {
11662
+ artifactId: prepared.artifact.id,
11663
+ index: built.index
11664
+ });
11665
+ phase("complete", completeStarted);
11666
+ return completed;
11667
+ };
11668
+ let completed;
11669
+ try {
11670
+ completed = await uploadAndComplete();
11671
+ } catch (error) {
11672
+ if (!isMissingModuleBlobCompleteError(error)) throw error;
11673
+ if (verbose) process.stdout.write("Retrying upload after missing module blob…\n");
11674
+ else process.stdout.write("Retrying upload…\n");
11675
+ completed = await uploadAndComplete();
11676
+ }
11660
11677
  if (verbose) process.stdout.write(`Deploy ${completed.artifact.id} started (${completed.mode})\n`);
11661
11678
  return completed.artifact.id;
11662
11679
  }
@@ -14203,4 +14220,4 @@ async function runCli(argv) {
14203
14220
  //#endregion
14204
14221
  export { runCli };
14205
14222
 
14206
- //# sourceMappingURL=program-Cb_jAhs0.mjs.map
14223
+ //# sourceMappingURL=program-CH1W0mPS.mjs.map