[PR #2272] [MERGED] Keep server logging alive when stdout closes #4164

Closed
opened 2026-11-03 04:15:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2272
Author: @rdbtCVS
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: rdbt/fix-1705-closed-stdout-d4113cff


📝 Commits (1)

  • 9e71837 Keep server logging from panicking on a closed stdout pipe

📊 Changes

1 file changed (+111 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/dedicated.rs (+111 -1)

📄 Description

🤖 Opened by rdbt's AI agent (OpenCode, GPT-6.1 Sol), not by rdbt himself.

What and why

Fixes #1705.

The shared server console logger uses println!, which panics when the launcher closes the game's stdout pipe. Player login reaches this logger and can consequently kill the integrated Server thread.

Use a best-effort writeln! on locked stdout, matching the fallible console writes in the main log writer. File logging and command capture run before the console write, and the existing timestamp/thread/level format is retained.

The regression runs the actual shared logger on a named Server thread in a subprocess. It checks ordinary console output, then closes the real stdout pipe before logging. Both cases verify file output and command capture, including a second thread name and WARN level.

Vanilla reference

The existing PlayerList.placeNewPlayer login path in game/lan.rs and Log4j console pattern in game/dedicated.rs. This is Rust console I/O handling; the regression exercises dedicated::log and log_from directly.

Self-check

Final required command: python3 tools/pr_ready.py --quick --base origin/main — exit 0, with isolated test homes.

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 9a7f75b75, 1 min 16 s)

Check Result
Scope ✅ 1 files, +111 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (6 s)
clippy ✅ (34 s)
tests: horizon-client ✅ 1313 passed (35 s)
doc tests ✅ 0 passed (1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Regression command: cargo test --locked -p horizon-client --bin horizon-client game::dedicated::tests::console_logging_survives_closed_stdout -- --exact.

  • Before the fix: 1 failed, reproducing thread 'Server thread' ... failed printing to stdout: Broken pipe (os error 32).
  • After the fix: 1 passed, 0 failed; normal console format, closed-stdout survival, file logging, and command capture all checked. The regression also passes in the complete quick self-check above.
  • Vanilla parity is left to CI as requested; no game resources are needed by the regression.

🤖 Generated with OpenCode (GPT-6.1 Sol).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2272 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `rdbt/fix-1705-closed-stdout-d4113cff` --- ### 📝 Commits (1) - [`9e71837`](https://github.com/horizon-rust/horizon/commit/9e71837df99a26c8ec77922d2718e8daeb46b2bd) Keep server logging from panicking on a closed stdout pipe ### 📊 Changes **1 file changed** (+111 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dedicated.rs` (+111 -1) </details> ### 📄 Description > 🤖 Opened by rdbt's AI agent (OpenCode, GPT-6.1 Sol), not by rdbt himself. ## What and why Fixes #1705. The shared server console logger uses `println!`, which panics when the launcher closes the game's stdout pipe. Player login reaches this logger and can consequently kill the integrated Server thread. Use a best-effort `writeln!` on locked stdout, matching the fallible console writes in the main log writer. File logging and command capture run before the console write, and the existing timestamp/thread/level format is retained. The regression runs the actual shared logger on a named Server thread in a subprocess. It checks ordinary console output, then closes the real stdout pipe before logging. Both cases verify file output and command capture, including a second thread name and WARN level. ## Vanilla reference The existing `PlayerList.placeNewPlayer` login path in `game/lan.rs` and Log4j console pattern in `game/dedicated.rs`. This is Rust console I/O handling; the regression exercises `dedicated::log` and `log_from` directly. ## Self-check Final required command: `python3 tools/pr_ready.py --quick --base origin/main` — **exit 0**, with isolated test homes. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 9a7f75b75, 1 min 16 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +111 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (6 s) | | clippy | ✅ (34 s) | | tests: horizon-client | ✅ 1313 passed (35 s) | | doc tests | ✅ 0 passed (1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Regression command: `cargo test --locked -p horizon-client --bin horizon-client game::dedicated::tests::console_logging_survives_closed_stdout -- --exact`. - Before the fix: **1 failed**, reproducing `thread 'Server thread' ... failed printing to stdout: Broken pipe (os error 32)`. - After the fix: **1 passed, 0 failed**; normal console format, closed-stdout survival, file logging, and command capture all checked. The regression also passes in the complete quick self-check above. - Vanilla parity is left to CI as requested; no game resources are needed by the regression. 🤖 Generated with [OpenCode](https://opencode.ai) (GPT-6.1 Sol). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:15:08 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4164
No description provided.