@matelink/cli 2026.4.14 → 2026.4.15
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/bin/matecli.mjs +42 -6
- package/package.json +1 -1
package/bin/matecli.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const NUMERIC_CODE_LENGTH = 4;
|
|
|
20
20
|
const GROUP_SIZE = 4;
|
|
21
21
|
const DEFAULT_RELAY_WORKER_WAIT_SECONDS = 600;
|
|
22
22
|
const DEFAULT_NETWORK_TIMEOUT_MS = 600000;
|
|
23
|
+
const BRIDGE_RETRY_DELAY_MS = 2000;
|
|
23
24
|
const DEFAULT_RELAY_URL = "http://43.134.64.199:8090";
|
|
24
25
|
const DEFAULT_GATEWAY_HOST = "127.0.0.1";
|
|
25
26
|
const DEFAULT_WEBHOOK_PATH = "/testnextim/webhook";
|
|
@@ -1210,6 +1211,27 @@ async function fetchWithTimeout(url, options = {}, timeoutMs = DEFAULT_NETWORK_T
|
|
|
1210
1211
|
}
|
|
1211
1212
|
}
|
|
1212
1213
|
|
|
1214
|
+
function isTransientNetworkError(error) {
|
|
1215
|
+
const message = String(error instanceof Error ? error.message : error).toLowerCase();
|
|
1216
|
+
return (
|
|
1217
|
+
message.includes("timeout") ||
|
|
1218
|
+
message.includes("fetch failed") ||
|
|
1219
|
+
message.includes("terminated") ||
|
|
1220
|
+
message.includes("socket") ||
|
|
1221
|
+
message.includes("econnreset") ||
|
|
1222
|
+
message.includes("econnrefused") ||
|
|
1223
|
+
message.includes("ehostunreach") ||
|
|
1224
|
+
message.includes("enotfound") ||
|
|
1225
|
+
message.includes("etimedout") ||
|
|
1226
|
+
message.includes("epipe") ||
|
|
1227
|
+
message.includes("network")
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
function sleep(ms) {
|
|
1232
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1213
1235
|
function normalizeGatewayIdRaw(value) {
|
|
1214
1236
|
return String(value ?? "")
|
|
1215
1237
|
.trim()
|
|
@@ -3331,12 +3353,26 @@ async function runRelayBridge({
|
|
|
3331
3353
|
const activeRequests = new Set();
|
|
3332
3354
|
|
|
3333
3355
|
while (true) {
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3356
|
+
let request;
|
|
3357
|
+
try {
|
|
3358
|
+
request = await readRelayNextGatewayRequest({
|
|
3359
|
+
relayUrl,
|
|
3360
|
+
gatewayId,
|
|
3361
|
+
gatewayToken,
|
|
3362
|
+
waitSeconds: DEFAULT_RELAY_WORKER_WAIT_SECONDS,
|
|
3363
|
+
});
|
|
3364
|
+
} catch (error) {
|
|
3365
|
+
if (!isTransientNetworkError(error)) {
|
|
3366
|
+
throw error;
|
|
3367
|
+
}
|
|
3368
|
+
if (!json) {
|
|
3369
|
+
console.warn(
|
|
3370
|
+
`[matecli] relay poll failed: ${String(error instanceof Error ? error.message : error)}; retrying in ${Math.round(BRIDGE_RETRY_DELAY_MS / 1000)}s`,
|
|
3371
|
+
);
|
|
3372
|
+
}
|
|
3373
|
+
await sleep(BRIDGE_RETRY_DELAY_MS);
|
|
3374
|
+
continue;
|
|
3375
|
+
}
|
|
3340
3376
|
if (!request) {
|
|
3341
3377
|
continue;
|
|
3342
3378
|
}
|