@nextclaw/server 0.11.7 → 0.11.8

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 +51 -6
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -3342,6 +3342,49 @@ var MARKETPLACE_ZH_COPY_BY_SLUG = {
3342
3342
  }
3343
3343
  };
3344
3344
 
3345
+ // src/ui/router/marketplace/marketplace-network-retry.ts
3346
+ var MARKETPLACE_NETWORK_RETRY_ATTEMPTS = 5;
3347
+ var MARKETPLACE_NETWORK_RETRY_BASE_MS = 350;
3348
+ function sleepMs(ms) {
3349
+ return new Promise((resolve2) => {
3350
+ setTimeout(resolve2, ms);
3351
+ });
3352
+ }
3353
+ function isRetryableMarketplaceNetworkError(error) {
3354
+ if (!(error instanceof Error)) {
3355
+ return false;
3356
+ }
3357
+ if (error.name === "AbortError") {
3358
+ return false;
3359
+ }
3360
+ const cause = error.cause;
3361
+ if (cause && typeof cause === "object" && cause !== null && "code" in cause) {
3362
+ const code = cause.code;
3363
+ if (code === "ECONNRESET" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "EPIPE" || code === "ENOTFOUND" || code === "EAI_AGAIN") {
3364
+ return true;
3365
+ }
3366
+ }
3367
+ if (error instanceof TypeError && error.message === "fetch failed") {
3368
+ return true;
3369
+ }
3370
+ return false;
3371
+ }
3372
+ async function runWithMarketplaceNetworkRetry(action) {
3373
+ let lastError;
3374
+ for (let attempt = 1; attempt <= MARKETPLACE_NETWORK_RETRY_ATTEMPTS; attempt += 1) {
3375
+ try {
3376
+ return await action();
3377
+ } catch (error) {
3378
+ lastError = error;
3379
+ if (attempt === MARKETPLACE_NETWORK_RETRY_ATTEMPTS || !isRetryableMarketplaceNetworkError(error)) {
3380
+ throw error;
3381
+ }
3382
+ await sleepMs(MARKETPLACE_NETWORK_RETRY_BASE_MS * 2 ** (attempt - 1));
3383
+ }
3384
+ }
3385
+ throw lastError;
3386
+ }
3387
+
3345
3388
  // src/ui/router/marketplace/catalog.ts
3346
3389
  function normalizeMarketplaceBaseUrl(options) {
3347
3390
  const configured = options.marketplace?.apiBaseUrl?.trim();
@@ -3363,12 +3406,14 @@ async function fetchMarketplaceData(params) {
3363
3406
  const endpoint = toMarketplaceUrl(params.baseUrl, params.path, params.query);
3364
3407
  let response;
3365
3408
  try {
3366
- response = await fetch(endpoint, {
3367
- method: "GET",
3368
- headers: {
3369
- Accept: "application/json"
3370
- }
3371
- });
3409
+ response = await runWithMarketplaceNetworkRetry(
3410
+ () => fetch(endpoint, {
3411
+ method: "GET",
3412
+ headers: {
3413
+ Accept: "application/json"
3414
+ }
3415
+ })
3416
+ );
3372
3417
  } catch (error) {
3373
3418
  return {
3374
3419
  ok: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/server",
3
- "version": "0.11.7",
3
+ "version": "0.11.8",
4
4
  "private": false,
5
5
  "description": "Nextclaw UI/API server.",
6
6
  "type": "module",
@@ -18,12 +18,12 @@
18
18
  "@hono/node-server": "^1.13.3",
19
19
  "hono": "^4.6.2",
20
20
  "ws": "^8.18.0",
21
+ "@nextclaw/mcp": "0.1.52",
21
22
  "@nextclaw/ncp": "0.4.0",
22
- "@nextclaw/openclaw-compat": "0.3.42",
23
- "@nextclaw/core": "0.11.5",
23
+ "@nextclaw/ncp-http-agent-server": "0.3.4",
24
24
  "@nextclaw/runtime": "0.2.19",
25
- "@nextclaw/mcp": "0.1.52",
26
- "@nextclaw/ncp-http-agent-server": "0.3.4"
25
+ "@nextclaw/core": "0.11.5",
26
+ "@nextclaw/openclaw-compat": "0.3.42"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^20.17.6",