fix: finalize interrupted bash via tool result path#21724
Conversation
7f7a22b to
38bfedc
Compare
38bfedc to
bab098f
Compare
|
@kitlangton I believe this regressed SIGPIPE handling as I've noticed Opencode closing without error/explanation. What follows is a Sonnet report. In the past this was caused by some bad scripting on my part, but it seems this time that's not the case. If the report doesn't seem bogus and I should create an issue I can do that. Environment is OSX with OpenCode running inside Docker (Ubuntu) (nothing new, been running it like this for a long while). Since v1.4.x, running a bash command that involves a pipe where the right side closes early (e.g. Reproduction: timeout 60s npx vue-tsc --noEmit 2>&1 | head -60The Root cause: In exitCode: Effect.flatMap(Deferred.await(signal), ([code, signal]) => {
if (Predicate.isNotNull(code)) return Effect.succeed(ExitCode(code))
return Effect.fail(
toPlatformError("exitCode", new Error(`Process interrupted due to receipt of signal: '${signal}'`), command)
)
})In SIGPIPE is normal and expected — it's not an error, it just means the consumer of a pipe stopped reading. It should be treated as exit code 141 (128 + 13) or simply as a non-zero exit. Suggested fix: In exitCode: Effect.flatMap(Deferred.await(signal), ([code, signal]) => {
if (Predicate.isNotNull(code)) return Effect.succeed(ExitCode(code))
// Treat signal exits as non-zero exit codes rather than failures
// SIGPIPE (13) → 141, SIGTERM (15) → 143, etc.
const sigNum = signalToNumber(signal) // or just return 128 as fallback
return Effect.succeed(ExitCode(128 + (sigNum ?? 0)))
})Alternatively, in |
Summary
Testing