Other v1.0.0

http-retry

触发词: timeouterror, econnreset, econnrefused, 429, retry, http error, 网络超时

2233admin 更新于 2026-02-24 1 浏览
下载 SKILL

技能说明

触发词: timeouterror, econnreset, econnrefused, 429, retry, http error, 网络超时

使用场景

触发词: timeouterror, econnreset, econnrefused, 429, retry, http error, 网络超时

查看英文原始说明

触发词: timeouterror, econnreset, econnrefused, 429, retry, http error, 网络超时

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

帮我下载并安装这个SKILL:https://skillhub.cstcloud.cn/download/http-retry
  1. 点击上方「下载 SKILL」按钮,获取技能压缩包。
  2. 将压缩包解压到你的 Agent 技能目录。
  3. 重启客户端后即可在技能列表中选择该技能。

技能文件内容

5 个文件 · 14 kB
SKILL.md text/markdown
# HTTP 重试技能

**触发词**: timeouterror, econnreset, econnrefused, 429, retry, http error, 网络超时

## 问题
网络请求失败(超时、连接重置、限流)导致服务不稳定

## 解决方案
指数退避 + 超时控制 + 连接池复用

```javascript
async function fetchWithRetry(url, options = {}, maxRetries = 3) {
  const { retryDelay = 1000, timeout = 30000 } = options;
  
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      const controller = new AbortController();
      const timeoutId = setTimeout(() => controller.abort(), timeout);
      const response = await fetch(url, { ...options, signal: controller.signal });
      clearTimeout(timeoutId);
      
      if (response.status === 429 || response.status >= 500) {
        await new Promise(r => setTimeout(r, retryDelay * Math.pow(2, attempt)));
        continue;
      }
      return response;
    } catch (err) {
      if (attempt === maxRetries) throw err;
      await new Promise(r => setTimeout(r, retryDelay * Math.pow(2, attempt)));
    }
  }
}
```

文件内容直接读取自技能仓库,仅供安装前审阅;以实际下载的压缩包为准。