Skip to content

审查报告:extra_body 实现一致性问题 + update.js 健壮性缺陷 #2

@grissomsh

Description

@grissomsh

背景

使用 /open-code-reviewf054bb7..d345ef9 范围的代码变更进行审查(14 个文件),发现以下需要关注的问题。


高优先级

1. scripts/update.js:自制 PID 文件锁存在 TOCTOU 竞态条件

acquireLock() 使用 process.kill(pid, 0) 检测进程存活,原进程可能在检测后退出、新进程可能复用该 PID,导致锁误判。建议使用 proper-lockfileflock

2. scripts/update.js:所有错误被静默吞掉

更新流程中的异常全部使用空 catch (_) 处理,失败时用户完全无感知。建议至少输出 console.error 或复用 install.js 中的 error() 工具函数。

3. scripts/update.js:Windows 兼容性

renameSync 在 Windows 上无法覆盖正在运行的可执行文件,且错误被静默吞掉。


中优先级

4. internal/llm/client.go + resolver.go:extra_body 合并逻辑不一致

doRequestCtx 已使用封装的 mergeExtraBody 函数处理 extra_body 合并和错误,但 client 的 Completions 方法和 resolver 的 StreamCompletion 方法仍然手动 json.Marshal/Unmarshal 且忽略错误,与项目其他位置不一致。建议统一使用 mergeExtraBody

5. scripts/publish/publish.sh:中断时 package.json 可能无法恢复

patch_package_json 修改 package.json 后,若在 publish 之前收到 SIGINT/SIGTERM,备份恢复逻辑不会触发。建议使用 trap EXIT 注册清理。

6. scripts/update.jssemverGt 实现过于简化

未处理预发布版本、不同长度版本号等情况,可能导致版本比较错误。

7. scripts/update.jscleanupTemp 未验证文件类型

直接 unlinkSync 匹配前缀的文件,如果存在符号链接可能误删其他文件。


低优先级

8. bin/ocr.js:spawn 子进程无错误处理

后台更新子进程失败时完全静默,不利于问题排查。

9. bin/ocr.js:时间戳写入时机不当

touchTimestamp() 在更新成功前调用,若更新中途失败,冷却期内会跳过真正的更新检查。

10. scripts/update.jsGITHUB_API_URL 硬编码

建议支持通过环境变量覆盖,便于企业代理或 GHE 环境使用。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions