Skip to content

fix(gateway): add encoding=utf-8, errors=replace to subprocess calls on Windows - #52846

Closed
ethanhuang996-alt wants to merge 4 commits into
NousResearch:mainfrom
ethanhuang996-alt:fix/gbk-encoding-crash
Closed

fix(gateway): add encoding=utf-8, errors=replace to subprocess calls on Windows#52846
ethanhuang996-alt wants to merge 4 commits into
NousResearch:mainfrom
ethanhuang996-alt:fix/gbk-encoding-crash

Conversation

@ethanhuang996-alt

Copy link
Copy Markdown

Problem

On Windows Chinese locale (GBK/CP936), subprocess.Popen/run(text=True) defaults to GBK encoding. When a subprocess outputs UTF-8 Chinese characters, the internal _readerthread crashes.

This causes: output pipe stalls, event loop blocked, WebSocket write timeout, window freezes, gateway restarts. errors.log showed 1,830 identical crash entries.

Fix

Add encoding=utf-8, errors=replace to 5 subprocess calls in:

  • tui_gateway/server.py (4 locations: _SlashWorker, quick command runner, API proxy)
  • tui_gateway/git_probe.py (1 location: git probe)

Verification

  • ast.parse() passes on both files
  • 20 consecutive subprocess runs with UTF-8 Chinese output, zero crashes
  • Environment: Windows 10 zh-CN, Python 3.12/3.14-rc

@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/desktop Electron desktop app (apps/desktop/*) platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jun 26, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by the consolidated Windows console-flash work tracked in #54220.

The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work.

Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants