Repository navigation
fix(engine): 已结束运行的 --run 日志止于读取时的文件末尾 - #277
Merged
Merged
Conversation
已退出、但还没有下一次运行记录接管位置的运行(最近一次结束的运行), 原来会得到没有终点的范围:--follow 会一直跟随同一文件,随后下一次运行 写入的字节就挂在了这次运行名下。范围现在带上 ended 状态,表示这次运行 不会再写出新行;读取时按打开文件看到的大小封口,把读的过程中才开始写入 的字节挡在外面。 Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
已退出、但还没有下一次运行记录接管位置的运行(最近一次结束的运行),
runLogRange得到end = -1的范围,bounded()为假,于是--follow走tail -c +N -f一直跟随同一文件。随后下一次运行写入这个文件,它的字节就出现在这次运行名下——文档承诺的「跟随一次已经结束的
运行会打印它的行然后停止」没有兑现。
改动
logRange增加ended状态:这次运行已经退出,不会再有属于它的字节。bounded()现在真正等于注释里的「最后一字节已经写完」。
runLogRange对status == exited一律标记ended;后续运行记录的接管位置仍然给出精确终点,没有记录时终点就是读取时的文件末尾。
readRunLines对ended且没有记录终点的范围,按打开文件时看到的大小封口,读的过程中才开始写入的字节也进不来。
docs/cli.md/docs/cli.zh.md同步该契约。验证(实际执行)
go test -count=1 -timeout=8m ./...(engine):全部通过,无 FAIL。go test -count=1 ./internal/cmd:通过。新增TestRunLogRangeOfANewestFinishedRunEndsAtTheFile与
TestFollowOfAFinishedRunWithoutASuccessorReturns;后者在修复前会卡 5 秒后报「跟随没有返回」,修复后立即返回。更新两处既有
runLogRange期望(exited 运行带ended)。gofmt -l ./internal/cmd、go vet ./internal/cmd:无输出。python3 scripts/check_docs.py:6 对文档一致。未跑:核心 race、真实服务场景(每日
Nightly full verification与发版流程覆盖)、Windows 构建。🤖 Generated with Claude Code