fix(logging): preserve failure exit on EPIPE · openclaw/openclaw@623a60a
steipete
·
2026-05-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -198,6 +198,24 @@ describe("enableConsoleCapture", () => {
|
198 | 198 | } |
199 | 199 | }); |
200 | 200 | |
| 201 | +it("preserves an existing nonzero exit code on async EPIPE", () => { |
| 202 | +const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {}) as typeof process.exit); |
| 203 | +const originalExitCode = process.exitCode; |
| 204 | +try { |
| 205 | +process.exitCode = 2; |
| 206 | +setLoggerOverride({ level: "info", file: tempLogPath() }); |
| 207 | +loggingState.streamErrorHandlersInstalled = false; |
| 208 | +enableConsoleCapture(); |
| 209 | +const epipe = new Error("write EPIPE") as NodeJS.ErrnoException; |
| 210 | +epipe.code = "EPIPE"; |
| 211 | +process.stderr.emit("error", epipe); |
| 212 | +expect(exitSpy).toHaveBeenCalledWith(2); |
| 213 | +} finally { |
| 214 | +process.exitCode = originalExitCode; |
| 215 | +exitSpy.mockRestore(); |
| 216 | +} |
| 217 | +}); |
| 218 | + |
201 | 219 | it("rethrows non-EPIPE errors on stdout", () => { |
202 | 220 | setLoggerOverride({ level: "info", file: tempLogPath() }); |
203 | 221 | enableConsoleCapture(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。