Skip to content

fix(desktop): handle broken console output pipes - #495

Merged
Wang-Daoji merged 1 commit into
MemTensor:v1.1.9from
Anson-Se:codex/fix-desktop-epipe
Sep 28, 2026
Merged

Wang-Daoji merged 1 commit into
MemTensor:v1.1.9from
Anson-Se:codex/fix-desktop-epipe

Conversation

@Anson-Se

Copy link
Copy Markdown
Contributor

When a launcher closes the read end of the desktop process's stdout/stderr pipe, subsequent UI logging can show an uncaught write EPIPE main-process dialog. This was reproduced on main (65c1825d) by closing a controlled output pipe and navigating between the welcome and token-detail pages; it is not specific to chat.

Handle EPIPE on stdout/stderr before initializing logging, disable the failed console transport for the remainder of the process, and preserve file logging. Log-level changes do not re-enable the broken transport. Other stream errors are rethrown, and repeated logger initialization does not add duplicate handlers.

Validation:

  • New regression tests failed on the original implementation and pass with the fix; cover stdout/stderr EPIPE, repeated errors, level changes, reinitialization, and unrelated errors.
  • Logger, log-level and log-rotation tests: 13 passed.
  • Desktop TypeScript compilation and subsequent --noEmit check passed; git diff --check passed.
  • Full Electron 38.4.0 application on macOS: after closing the pipe's reader, repeated page navigation no longer shows the dialog and main.log continues receiving page-view records.
  • Full desktop suite: 252 passed, 106 skipped, 1 failed (memory-restart-lifecycle.test.ts: Memory exits before readiness, code 1). The same failure reproduces with the logger source restored to upstream main in this environment (Node 26.0.0).

Packaged releases and other operating systems were not exercised. This does not address the separate conversation-context behavior observed during investigation.

@Anson-Se
Anson-Se requested a review from ZongYue99 as a code owner September 20, 2026 07:16
Copilot AI lite review requested due to automatic review settings September 20, 2026 07:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused tests and implementation correctly preserve file logging while suppressing only the failed console transport.

Review effort: Lite
Findings: None

What changed in this PR

Fixes desktop stdout/stderr EPIPE failures without interrupting the main process or file logging.

Changes:

  • Installs one-time stream error handlers and disables the console transport after EPIPE.
  • Preserves file logging and console transport state across log-level changes and reinitialization.
  • Adds regression tests for stream failures and logger lifecycle behavior.
File Description
App/​shell/​desktop/​src/​main/​logger.ts Handles broken console output pipes safely.
App/​shell/​desktop/​tests/​logger.test.ts Covers EPIPE, unrelated errors, and reinitialization.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Wang-Daoji
Wang-Daoji changed the base branch from main to v1.1.9 September 28, 2026 08:54
@Wang-Daoji
Wang-Daoji merged commit 613640b into MemTensor:v1.1.9 Sep 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants