[Bug] dsh web crashes with ENOENT when external temp cleanup removes the subprocess spill dir #3190
Replies: 2 comments
|
对照当前 main HEAD
补充三点: 1. 仓库里已经有现成的降级模式,建议复用而不是新造
if (!this.spillDisabled && (overflows || this.spillFd !== undefined)) {
try { this.spillAll(chunk) } catch (error) {
if (error?.code === 'ENOENT' || error?.code === 'EPERM') {
this.spillDisabled = true // degrade to in-memory tail, keep the harness alive
// log once
} else throw error
}
}这对应你建议里的方案 2,改动面最小; 2. 崩溃点不止 openSync
3. 回归测试建议
另外你的方案 3(退出时清理)不解决中途删除问题,作为补充可以但别当主修复——README 明确设计为"完成即保留、由外部清理",所以对目录消失的容错才是正解。 |
类似情况的另一种参考:在缓存命中分支补一个存在性检查与重建。安全性:runner 每次调用都会重新授予 temp SID 写权限( // packages/sandbox/sandbox-local/src/index.ts
const existing = this.tempCapabilities.get(key)
if (existing !== undefined) {
// OS temp hygiene or manual cleanup can remove the materialized
// directory between calls; recreate it so the runner's --temp
// validation still passes (the runner re-grants the temp SID).
if (!existsSync(existing.dir)) mkdirSync(existing.dir, { recursive: true })
return existing
}备选方案:
|
Uh oh!
There was an error while loading. Please reload this page.
@{title=[Bug] dsh web crashes with ENOENT when OS temp cleanup removes the subprocess spill dir (Windows); body=## Summary
dsh webcrashes with an uncaughtENOENTwhen the OS (or any external tool) cleans%TEMP%while dsh is running. The private per-process spill directory created bydsh-subprocess-localdisappears mid-run, so the next stdout write from a spawned subprocess fails hard and takes down the whole harness.This is on Windows 11 24H2, node v24.18.1, dsh
0.1.0-rc.7.Crash stack
Root cause analysis
privateSpillDir()(dsh-subprocess-locallib/index.js:348-350) lazily creates onemkdtempSyncdirectory per dsh process under the OS tmpdir:%TEMP%\dsh-subprocess-XXXXXX.OutputCollector.spillAll()(:417) callsopenSync(..., 'wx')to append a spawned subprocess's stdout/stderr once the in-memory cap overflows.%TEMP%\dsh-subprocess-*while dsh is still running, the nextopenSyncthrowsENOENTand it is uncaught → the whole dsh process crashes. The session log is cleanly truncated mid tool-call; there is no error event written anywhere.Repro steps
dsh web(any profile that spawns subprocesses / bash tools).%TEMP%\dsh-subprocess-*directory belonging to that process.Suggested fix
Make the spill path resilient to directory loss, e.g.:
openSync/writeSyncin try/catch and lazily re-create the per-process dir on failure (fs.mkdirSync(dir, { recursive: true })), orENOENTinspillAlland degrade to in-memory tail (markspillDisabled) instead of crashing, orexitso long-running installs don't accumulate, and tolerate a missing dir as a no-op.Happy to provide more detail or test a patch.; category_ids=System.Object[]}.body
All reactions