Repository navigation
fix(bash-ipc): retry a transiently refused quarantine (#352) - #354
Merged
Merged
Conversation
Richeir
marked this pull request as ready for review
October 21, 2026 05:29
# Conflicts: # docs/CHANGELOG.md
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.
Closes #352
What was wrong
bash-ipc把校验通过的 MSYS 运行时缓存在$DSH_HOME/dsh-ops/bash-ipc/<id>。一旦某个 generation 校验失败,confinedBash会先把它重命名成<id>.bad-<base36>隔离,再重新 staging 一份;这个重命名是单次fs.renameSync,第一次被拒就是终局:在 Windows 11 26100 上,树刚写完的约 1.5 秒内这条 rename 会被拒,之后就能成功——换另一个进程也一样,且本机实时防病毒是关闭的:
于是恢复路径把一个片刻后就消失的条件报成了"无法隔离",
bash-ipc套件在本机确定性变红(修复前 3/3),提示语还让用户去停一个根本没在跑的 shell。复现:
npm ci --ignore-scripts && npm run build:ptc && npm run build:bash-ipc && node test/run.mjs bash-ipc。The change
src/bash-ipc.ts:新增renameWithRetry(),只对EPERM/EBUSY/EACCES做 100/200/400/800 ms 的有界退避(合计 1.5 s,即实测窗口);其它错误码、以及最后一次退避之后的失败,仍然立刻抛出。发布用的 rename(stage→target)走同一个助手。quarantineGeneration(),保留原有"只留最近两份"的清理与日志;错误文案改为 "could not be quarantined after retrying",并把剩余原因写成"有受限 shell 或其它进程仍在使用"。test/bash-ipc.test.mjs:renameWithRetry补单测(两次拒绝被吸收、ENOENT只试一次、尝试次数等于 delays + 1);quarantineGeneration用注入的瞬时EPERM断言隔离最终完成(生成同级隔离目录、原目录消失),再用永久拒绝断言尝试次数恰为RENAME_RETRY_DELAYS_MS.length + 1且目录保持原样。docs/CHANGELOG.md:## [Unreleased]双语条目。刻意没做:没有改动"校验通过"的判定,没有新增依赖,没有改变隔离保留份数;重试也不在每命令热路径上——只有 generation 已经校验失败时才会走这里。
rename/wait可注入,只是为了让测试能构造确定性失败,而不用真的睡 1.5 秒。Validation
pull_request事件触发的CI requiredrun,URL 见下方代码块npm run verify的实际输出(见代码块)docs/CHANGELOG.md的## [Unreleased]已加条目package.json的版本与optionalDependencies红绿对照:把
RENAME_RETRY_DELAYS_MS临时改成[](等价于单次尝试)并重建,两条检查立刻变红——既有那条篡改用例(真实EPERM窗口)和新加的注入用例:4 个 skip 都是平台性的:
linux-attributes与linux-shell是 POSIX 概念,两个 TUI 套件需要DSH_OPS_TUI_ROOT。Environment
main的a9ff940(0.4.1);安装通道:源码检出,npm ci --ignore-scripts(安装@dsh-ops/[email protected])、npm run build:ptc、npm run build:bash-ipc