@agile-team/robot-cli 3.0.2 → 3.0.3
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/CHANGELOG.md +8 -0
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [3.0.3] - 2026-03-29
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **根治下载超时的真正根因** — `AbortSignal.timeout(ms)` 是总时限(含 body 流式下载),大文件(10-20MB)在国内网络 30 秒内根本下不完,必然中断
|
|
13
|
+
- 改用 `AbortController` + 手动 `clearTimeout`:只对"连接建立/收到响应头"计时(30s),一旦连接成功立即取消计时器,body 流式下载不再受任何时间限制
|
|
14
|
+
- 与 v1.x 的 `node-fetch` `timeout` 行为完全一致(活跃超时,而非总时限)
|
|
15
|
+
|
|
8
16
|
## [3.0.2] - 2026-03-29
|
|
9
17
|
|
|
10
18
|
### Fixed
|
package/dist/index.js
CHANGED
|
@@ -404,18 +404,21 @@ function buildDownloadSources(repoUrl, branch, giteeUrl) {
|
|
|
404
404
|
}
|
|
405
405
|
return sources;
|
|
406
406
|
}
|
|
407
|
-
async function fetchWithRetry(downloadUrl,
|
|
407
|
+
async function fetchWithRetry(downloadUrl, connectionTimeoutMs, retries, extraHeaders) {
|
|
408
408
|
let lastError;
|
|
409
409
|
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
410
|
+
const controller = new AbortController();
|
|
411
|
+
const timer = setTimeout(() => controller.abort(), connectionTimeoutMs);
|
|
410
412
|
try {
|
|
411
413
|
const response = await fetch(downloadUrl, {
|
|
412
|
-
signal:
|
|
414
|
+
signal: controller.signal,
|
|
413
415
|
redirect: "follow",
|
|
414
416
|
headers: {
|
|
415
417
|
"User-Agent": "Robot-CLI/3.0",
|
|
416
418
|
...extraHeaders
|
|
417
419
|
}
|
|
418
420
|
});
|
|
421
|
+
clearTimeout(timer);
|
|
419
422
|
if (!response.ok) {
|
|
420
423
|
if (response.status === 404) throw new Error(`\u4ED3\u5E93\u4E0D\u5B58\u5728 (404)`);
|
|
421
424
|
throw new Error(`HTTP ${response.status}`);
|
|
@@ -426,6 +429,7 @@ async function fetchWithRetry(downloadUrl, timeout, retries, extraHeaders) {
|
|
|
426
429
|
}
|
|
427
430
|
return response;
|
|
428
431
|
} catch (error) {
|
|
432
|
+
clearTimeout(timer);
|
|
429
433
|
lastError = error;
|
|
430
434
|
if (lastError.message.includes("404")) throw lastError;
|
|
431
435
|
if (attempt < retries) {
|