fix(daemon): prefer stderr over stale stdout in gateway restart diagn… · openclaw/openclaw@f6a3ac7
Alix-007
·
2026-06-16
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -36,4 +36,21 @@ describe("readLastGatewayErrorLine", () => {
|
36 | 36 | "gateway stdout current", |
37 | 37 | ); |
38 | 38 | }); |
| 39 | + |
| 40 | +it("prefers the current stderr error over a stale stdout match on linux", async () => { |
| 41 | +const stateDir = makeTempStateDir(); |
| 42 | +const homeDir = makeTempStateDir(); |
| 43 | +const env = { HOME: homeDir, OPENCLAW_STATE_DIR: stateDir }; |
| 44 | +const stateLogs = resolveGatewayLogPaths(env); |
| 45 | +fs.mkdirSync(stateLogs.logDir, { recursive: true }); |
| 46 | +// stderr carries the real, current failure; stdout carries an older matching |
| 47 | +// line. On non-darwin platforms stderr is the strongest failure signal, so |
| 48 | +// it must win instead of the stale stdout match. |
| 49 | +fs.writeFileSync(stateLogs.stderrPath, "failed to bind gateway socket EADDRINUSE\n", "utf8"); |
| 50 | +fs.writeFileSync(stateLogs.stdoutPath, "gateway start blocked: stale prior reason\n", "utf8"); |
| 51 | + |
| 52 | +await expect(readLastGatewayErrorLine(env, { platform: "linux" })).resolves.toBe( |
| 53 | +"failed to bind gateway socket EADDRINUSE", |
| 54 | +); |
| 55 | +}); |
39 | 56 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。