myagent-ai 1.23.68 → 1.23.69
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/core/update_manager.py +37 -3
- package/package.json +1 -1
package/core/update_manager.py
CHANGED
|
@@ -900,6 +900,10 @@ class UpdateManager:
|
|
|
900
900
|
if registry != "https://registry.npmjs.org":
|
|
901
901
|
registries_to_try.append(registry) # 镜像作为备用
|
|
902
902
|
|
|
903
|
+
# E404 重试: 新版本刚发布时 CDN 可能尚未传播,最多等待 3 分钟
|
|
904
|
+
max_404_retries = 6
|
|
905
|
+
retry_interval = 30 # 秒
|
|
906
|
+
|
|
903
907
|
last_error = None
|
|
904
908
|
for reg in registries_to_try:
|
|
905
909
|
is_official = (reg == "https://registry.npmjs.org")
|
|
@@ -925,15 +929,45 @@ class UpdateManager:
|
|
|
925
929
|
error_msg = npm_output[-500:] if npm_output else "未知错误"
|
|
926
930
|
# 检查是否包含真正的错误
|
|
927
931
|
has_real_error = False
|
|
932
|
+
is_404 = False
|
|
928
933
|
for line in error_msg.split("\n"):
|
|
929
934
|
stripped = line.strip()
|
|
930
935
|
if stripped.startswith("ERR!") or "code E" in stripped:
|
|
931
936
|
has_real_error = True
|
|
932
|
-
|
|
937
|
+
if "code E404" in stripped or "Not Found" in stripped and pkg_name in stripped:
|
|
938
|
+
is_404 = True
|
|
933
939
|
if has_real_error:
|
|
934
940
|
last_error = error_msg
|
|
935
|
-
|
|
936
|
-
|
|
941
|
+
if is_404:
|
|
942
|
+
# E404: 新版本尚未传播到该 registry,等待后重试
|
|
943
|
+
remaining = max_404_retries
|
|
944
|
+
while remaining > 0:
|
|
945
|
+
remaining -= 1
|
|
946
|
+
logger.warning(
|
|
947
|
+
f"npm install 通过 {'官方源' if is_official else '镜像源'} 失败 (E404,新版本尚未传播),"
|
|
948
|
+
f"{retry_interval}秒后重试 (剩余 {remaining} 次)..."
|
|
949
|
+
)
|
|
950
|
+
await asyncio.sleep(retry_interval)
|
|
951
|
+
result = await loop.run_in_executor(
|
|
952
|
+
None,
|
|
953
|
+
lambda cmd=npm_cmd: subprocess.run(
|
|
954
|
+
cmd,
|
|
955
|
+
capture_output=True, text=True, timeout=300,
|
|
956
|
+
)
|
|
957
|
+
)
|
|
958
|
+
npm_output = result.stdout + result.stderr
|
|
959
|
+
record.details["update_output"] = npm_output[:2000]
|
|
960
|
+
logger.info(f"npm update retry ({'official' if is_official else 'mirror'}): {npm_output[:500]}")
|
|
961
|
+
if result.returncode == 0 or "code E404" not in npm_output:
|
|
962
|
+
# 成功或非 404 错误,跳出重试
|
|
963
|
+
break
|
|
964
|
+
else:
|
|
965
|
+
# 重试耗尽,放弃该源
|
|
966
|
+
logger.error(f"npm install E404 重试 {max_404_retries} 次仍失败,跳过该源")
|
|
967
|
+
continue
|
|
968
|
+
else:
|
|
969
|
+
logger.warning(f"npm install 通过 {'官方源' if is_official else '镜像源'} 失败,尝试{'镜像源' if is_official else '官方源'}")
|
|
970
|
+
continue
|
|
937
971
|
else:
|
|
938
972
|
logger.warning(f"npm install 有警告但可能已成功: {error_msg}")
|
|
939
973
|
# 安装成功或只有警告,跳出循环
|