# 错误：操作已中止。（边缘运行时：由于超时或取消而中止的 fetch）

- **ID:** `nextjs/edge-runtime-fetch-abort`
- **领域:** nextjs
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在边缘运行时（例如中间件、边缘 API 路由）中，fetch 请求默认超时为 30 秒，如果响应太慢或客户端断开连接，运行时可能会中止请求。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Next.js 13.x | active | — | — |
| Next.js 14.x | active | — | — |
| Next.js 15.x | active | — | — |
| Edge Runtime (Vercel) | active | — | — |

## 解决方案

1. ```
   Optimize the external API response time (e.g., use caching, reduce payload size) to ensure it completes within 30 seconds. Alternatively, use a server-side data fetching pattern with incremental static regeneration (ISR) to avoid real-time fetch.
   ```
2. ```
   Move the fetch to a server component (Node.js runtime) where there is no 30-second timeout limit. Use the edge runtime only for lightweight operations.
   ```

## 无效尝试

- **** — The Edge Runtime has a hard limit of 30 seconds for fetch; this cannot be overridden. The config option may not exist or be ignored in edge. (80% 失败率)
- **** — The runtime will still abort at 30 seconds even if the AbortController signal is set to a longer timeout. (70% 失败率)
- **** — If the route is already on edge, the runtime is fixed; moving to Node.js may require other changes (e.g., removing edge-specific APIs). (50% 失败率)
