ardent-cli 0.0.20 → 0.0.21

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -307,6 +307,19 @@ function isPermissionError(err) {
307
307
  }
308
308
  return false;
309
309
  }
310
+ var API_ERROR_PREFIX = /^api error \d{3}:/;
311
+ function isGatewayTimeoutError(err) {
312
+ if (err instanceof Error) {
313
+ const msg = err.message.toLowerCase();
314
+ if (msg.includes("api error 502") || msg.includes("api error 503") || msg.includes("api error 504")) {
315
+ return true;
316
+ }
317
+ if (API_ERROR_PREFIX.test(msg)) {
318
+ return false;
319
+ }
320
+ }
321
+ return isNetworkError(err);
322
+ }
310
323
 
311
324
  // src/lib/telemetry.ts
312
325
  import { randomUUID } from "crypto";
@@ -729,6 +742,52 @@ Example:
729
742
  }
730
743
 
731
744
  // src/commands/connector/create.ts
745
+ var EngineSetupTimeoutError = class extends Error {
746
+ constructor(message) {
747
+ super(message);
748
+ this.name = "EngineSetupTimeoutError";
749
+ }
750
+ };
751
+ async function runEngineSetupWithPolling(connectorId) {
752
+ try {
753
+ await api.post(`/v1/connectors/${connectorId}/engine-setup`, {});
754
+ return;
755
+ } catch (err) {
756
+ if (!isGatewayTimeoutError(err)) {
757
+ throw err;
758
+ }
759
+ console.log(
760
+ " Backend engine setup is long-running; the gateway dropped the request but the work continues server-side. Polling for completion..."
761
+ );
762
+ }
763
+ const startedAt = Date.now();
764
+ const maxWaitMs = 20 * 60 * 1e3;
765
+ const pollIntervalMs = 30 * 1e3;
766
+ while (Date.now() - startedAt < maxWaitMs) {
767
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
768
+ let status;
769
+ try {
770
+ status = await api.get(`/v1/connectors/${connectorId}`);
771
+ } catch (pollErr) {
772
+ if (isGatewayTimeoutError(pollErr)) continue;
773
+ throw pollErr;
774
+ }
775
+ const engineStatus = status.branching_engine_status;
776
+ if (engineStatus === "healthy" || engineStatus === "degraded") {
777
+ return;
778
+ }
779
+ if (engineStatus === "configuration_failed" || engineStatus === "failed_validation") {
780
+ throw new Error(
781
+ `Engine setup failed (status: ${engineStatus}). Check connector status: ardent connector list`
782
+ );
783
+ }
784
+ const elapsedSec = Math.round((Date.now() - startedAt) / 1e3);
785
+ console.log(` Still setting up... (${elapsedSec}s elapsed, status=${engineStatus ?? "unknown"})`);
786
+ }
787
+ throw new EngineSetupTimeoutError(
788
+ `Engine setup did not complete within ${maxWaitMs / 6e4} minutes. Setup may still be running server-side \u2014 do NOT delete the connector. Check status with: ardent connector list`
789
+ );
790
+ }
732
791
  function parsePostgresUrl(url) {
733
792
  const atIndex = url.lastIndexOf("@");
734
793
  const credentialsPart = atIndex > 0 ? url.substring(0, atIndex) : url;
@@ -853,10 +912,12 @@ async function createAction2(type, url, options) {
853
912
  if (isByoc) {
854
913
  console.log("Setting up branching engine...");
855
914
  try {
856
- await api.post(`/v1/connectors/${connectorId}/engine-setup`, {});
915
+ await runEngineSetupWithPolling(connectorId);
857
916
  } catch (setupErr) {
858
- console.error("\u2717 Engine setup failed. To retry, delete and recreate:");
859
- console.error(` ardent connector delete ${connectorName}`);
917
+ if (!(setupErr instanceof EngineSetupTimeoutError)) {
918
+ console.error("\u2717 Engine setup failed. To retry, delete and recreate:");
919
+ console.error(` ardent connector delete ${connectorName}`);
920
+ }
860
921
  throw setupErr;
861
922
  }
862
923
  } else {
@@ -882,7 +943,7 @@ async function createAction2(type, url, options) {
882
943
  const connector = await api.get(`/v1/connectors/${connectorId}`);
883
944
  if (connector.branching_engine_status === "configuration_verified") {
884
945
  console.log("Setting up branching engine...");
885
- await api.post(`/v1/connectors/${connectorId}/engine-setup`, {});
946
+ await runEngineSetupWithPolling(connectorId);
886
947
  }
887
948
  }
888
949
  const finalConnector = await api.get(`/v1/connectors/${connectorId}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ardent-cli",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "Git for Data infrastructure",
5
5
  "type": "module",
6
6
  "bin": {