fix(gateway): guard faulthandler.enable() against sys.stderr=None on Windows - #72158
Closed
brantleyjill wants to merge 1 commit into
Closed
fix(gateway): guard faulthandler.enable() against sys.stderr=None on Windows#72158brantleyjill wants to merge 1 commit into
brantleyjill wants to merge 1 commit into
Conversation
…Windows
faulthandler.enable() crashes with RuntimeError('sys.stderr is None')
when the gateway is spawned as a subprocess without a TTY on Windows,
because faulthandler defaults to writing to sys.stderr which is None
in that context.
This breaks 'hermes gateway start' (direct spawn) and desktop-app
backend launch ('hermes serve' spawned by Electron), producing
exit code 1 and 'Could not connect to hermes gateway' in the UI.
Fix: guard with 'if sys.stderr is not None:' before calling
faulthandler.enable().
Collaborator
Contributor
|
Thanks for the fix — this was a real bug and your guard was correct. It landed via PR #72304, which salvaged #71671 (the same fix submitted ~18h earlier, with a file-fallback so faulthandler stack dumps still work when stderr is missing, plus a regression test). Closing this one as a duplicate; appreciate the report and the diff. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
faulthandler.enable()crashes withRuntimeError: sys.stderr is Nonewhen the gateway is spawned as a subprocess without a TTY on Windows. This happens because faulthandler defaults to writing tosys.stderr, which isNonein that context.This breaks two scenarios:
hermes gateway start— spawns the gateway as a child process, crashes immediately with exit code 1hermes servespawned by Electron) — same crash, producing "Could not connect to hermes gateway" in the UIThe crash happens at
gateway/run.py:7821.Fix
Wrap
faulthandler.enable()with aif sys.stderr is not None:guard. This preserves the faulthandler behavior on platforms wheresys.stderris available (Linux, macOS, Windows with TTY) while preventing the crash on headless child processes.Verification
hermes gateway startreturns success and process stays running