ardent-cli 0.0.47 → 0.0.49
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.js +34 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -384,6 +384,15 @@ function isGatewayTimeoutError(err) {
|
|
|
384
384
|
}
|
|
385
385
|
return isNetworkError(err);
|
|
386
386
|
}
|
|
387
|
+
function isTransientOperationPollError(err) {
|
|
388
|
+
if (isGatewayTimeoutError(err)) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
if (!(err instanceof Error)) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
return err.message.trim().toLowerCase() === "api error 500: internal server error";
|
|
395
|
+
}
|
|
387
396
|
|
|
388
397
|
// src/lib/connector_selection.ts
|
|
389
398
|
function clearSelectedConnector() {
|
|
@@ -1153,17 +1162,18 @@ var DiscoveryTimeoutError = class extends Error {
|
|
|
1153
1162
|
};
|
|
1154
1163
|
var DiscoveryOperationFailedError = class extends Error {
|
|
1155
1164
|
operationError;
|
|
1156
|
-
constructor(operationError) {
|
|
1165
|
+
constructor(operationError, recoveryGuidance) {
|
|
1157
1166
|
super(
|
|
1158
|
-
`Discovery failed: ${operationError ?? "unknown error"}. Inspect the connector with \`ardent connector list\`, fix the underlying issue, then
|
|
1167
|
+
`Discovery failed: ${operationError ?? "unknown error"}. Inspect the connector with \`ardent connector list\`, fix the underlying issue, then ${recoveryGuidance}.`
|
|
1159
1168
|
);
|
|
1160
1169
|
this.name = "DiscoveryOperationFailedError";
|
|
1161
1170
|
this.operationError = operationError;
|
|
1162
1171
|
}
|
|
1163
1172
|
};
|
|
1164
1173
|
async function runDiscoveryWithPolling(connectorId, options) {
|
|
1165
|
-
const maxWaitMs = options
|
|
1166
|
-
const pollIntervalMs = options
|
|
1174
|
+
const maxWaitMs = options.maxWaitMs ?? 10 * 60 * 1e3;
|
|
1175
|
+
const pollIntervalMs = options.pollIntervalMs ?? 3 * 1e3;
|
|
1176
|
+
const recoveryGuidance = options.recoveryGuidance;
|
|
1167
1177
|
let dispatch;
|
|
1168
1178
|
try {
|
|
1169
1179
|
dispatch = await api.post(
|
|
@@ -1178,7 +1188,7 @@ async function runDiscoveryWithPolling(connectorId, options) {
|
|
|
1178
1188
|
}
|
|
1179
1189
|
throw err;
|
|
1180
1190
|
}
|
|
1181
|
-
if (options
|
|
1191
|
+
if (options.onPrerequisites) {
|
|
1182
1192
|
options.onPrerequisites(dispatch.prerequisites, dispatch.source_metadata);
|
|
1183
1193
|
}
|
|
1184
1194
|
const operationId = dispatch.operation_id;
|
|
@@ -1210,7 +1220,7 @@ async function runDiscoveryWithPolling(connectorId, options) {
|
|
|
1210
1220
|
};
|
|
1211
1221
|
}
|
|
1212
1222
|
if (op.status === "failed") {
|
|
1213
|
-
throw new DiscoveryOperationFailedError(op.error);
|
|
1223
|
+
throw new DiscoveryOperationFailedError(op.error, recoveryGuidance);
|
|
1214
1224
|
}
|
|
1215
1225
|
}
|
|
1216
1226
|
throw new DiscoveryTimeoutError(
|
|
@@ -1305,6 +1315,9 @@ function assertEngineSetupCompleted(operation, connectorName) {
|
|
|
1305
1315
|
}
|
|
1306
1316
|
|
|
1307
1317
|
// src/lib/engine_setup.ts
|
|
1318
|
+
var ENGINE_SETUP_MAX_WAIT_MS = 60 * 60 * 1e3;
|
|
1319
|
+
var ENGINE_SETUP_POLL_INTERVAL_MS = 5 * 1e3;
|
|
1320
|
+
var ENGINE_SETUP_TRANSIENT_WARN_EVERY = 6;
|
|
1308
1321
|
var EngineSetupTimeoutError = class extends Error {
|
|
1309
1322
|
constructor(message) {
|
|
1310
1323
|
super(message);
|
|
@@ -1321,7 +1334,7 @@ var EngineSetupOperationFailedError = class extends Error {
|
|
|
1321
1334
|
this.operationError = operationError;
|
|
1322
1335
|
}
|
|
1323
1336
|
};
|
|
1324
|
-
async function runEngineSetupWithPolling(connectorId, connectorName) {
|
|
1337
|
+
async function runEngineSetupWithPolling(connectorId, connectorName, options = {}) {
|
|
1325
1338
|
let dispatch;
|
|
1326
1339
|
try {
|
|
1327
1340
|
dispatch = await api.post(
|
|
@@ -1341,18 +1354,28 @@ async function runEngineSetupWithPolling(connectorId, connectorName) {
|
|
|
1341
1354
|
return { dispatched: false };
|
|
1342
1355
|
}
|
|
1343
1356
|
const startedAt = Date.now();
|
|
1344
|
-
const maxWaitMs =
|
|
1345
|
-
const pollIntervalMs =
|
|
1357
|
+
const maxWaitMs = options.maxWaitMs ?? ENGINE_SETUP_MAX_WAIT_MS;
|
|
1358
|
+
const pollIntervalMs = options.pollIntervalMs ?? ENGINE_SETUP_POLL_INTERVAL_MS;
|
|
1346
1359
|
let lastStage = null;
|
|
1360
|
+
let consecutiveTransientFailures = 0;
|
|
1347
1361
|
while (Date.now() - startedAt < maxWaitMs) {
|
|
1348
1362
|
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
1349
1363
|
let op;
|
|
1350
1364
|
try {
|
|
1351
1365
|
op = await api.get(`/v1/operations/${operationId}`);
|
|
1352
1366
|
} catch (pollErr) {
|
|
1353
|
-
if (
|
|
1367
|
+
if (isTransientOperationPollError(pollErr)) {
|
|
1368
|
+
consecutiveTransientFailures += 1;
|
|
1369
|
+
if (consecutiveTransientFailures % ENGINE_SETUP_TRANSIENT_WARN_EVERY === 0) {
|
|
1370
|
+
console.warn(
|
|
1371
|
+
` \u26A0 Status check has failed ${consecutiveTransientFailures} times in a row. Setup is still running server-side and the CLI will keep waiting \u2014 do NOT delete the connector.`
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1354
1376
|
throw pollErr;
|
|
1355
1377
|
}
|
|
1378
|
+
consecutiveTransientFailures = 0;
|
|
1356
1379
|
if (op.stage && op.stage !== lastStage) {
|
|
1357
1380
|
const progressLabel = op.progress != null ? ` (${op.progress}%)` : "";
|
|
1358
1381
|
console.log(` ${operationStageDisplay(op.stage)}${progressLabel}`);
|
|
@@ -2205,6 +2228,7 @@ async function createAction2(type, url, options) {
|
|
|
2205
2228
|
let discoverPollResult;
|
|
2206
2229
|
try {
|
|
2207
2230
|
discoverPollResult = await runDiscoveryWithPolling(connectorId, {
|
|
2231
|
+
recoveryGuidance: `delete the connector with \`ardent connector delete ${connectorName}\`, then run \`ardent connector create\` again`,
|
|
2208
2232
|
onPrerequisites: (prereqs) => {
|
|
2209
2233
|
if (prereqs.pass) {
|
|
2210
2234
|
console.log("Connected \u2713 \u2014 scanning your schema\u2026");
|