Repository navigation
fix(electron): wait for Python detection output before resolving - #122
Merged
protocorn merged 1 commit intoNov 25, 2026
Merged
Conversation
protocorn
reviewed
Nov 17, 2026
protocorn
left a comment
Owner
There was a problem hiding this comment.
Thanks @BitsRevenge — this is a solid fix for #114, and we appreciate you picking it up.
Review of 6e78290988de6dc42528e7dfb4749089596b01a9
What's good
- Switching
runCommand()from'exit'to'close'is the right fix.'close'fires after stdout and stderr have ended, so the version check no longer races a latePython 3.xline. - The optional
spawnProcesshook keeps runtime behavior the same and lets the tests drive a fake child. - The tests cover the actual race (exit, then late stdout, then close), a non-zero exit with stderr, and a spawn error. Promise resolution is naturally one-shot, so a later
closeaftererrordoes not overwrite the result. - Diagnostics now log the real executable (not a hardcoded
python --version), plus the exit code and stderr, including after winget/Homebrew install and on an incompatible version. That covers the Windows, macOS, and Linux probe paths. - CI on this head is green: Test and Electron MCP paths on Ubuntu and Windows, Electron renderer lint, Linux and Windows builds, and GitGuardian. The macOS build was skipped, which is the usual pattern here.
Notes (not blocking)
runCommand()still has no timeout, same as before this PR. That is fine for this fix.- This PR and #121 both add
electron-ui/electron/lib/api-spawn.test.jsfrommain. Theapi-spawn.jsedits themselves should combine cleanly, but the new test file will conflict. After one of them is merged, the other will need a short rebase so both test suites are kept.
Verdict: Looks good to merge, pending Sahil.
(Clippy GitHub Maintainer Bot, an AI assistant helping maintain this repo.)
9 of 19 tasks
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.
Pull Request
Description
Fixes a potential race condition in Python version detection during first-time setup.
Previously,
runCommand()resolved on the child process'sexitevent, which can occur before stdout and stderr have been fully read. This could cause Python detection to receive an empty version output even when Python 3.11+ is installed.The change waits for the
closeevent and improves Python detection diagnostics to make failures easier to investigate.Type of change
Related issue
Closes #114
Changes made
runCommand()to resolve oncloseinstead ofexit, ensuring stdout and stderr streams have closed before returning the result.Testing
Test results
Child-process regression tests
node --test electron/lib/api-spawn.test.jsexitbehavior: 2 failed, 1 passed.closebehavior: 3 passed, 0 failed.The tests simulate a child process emitting
exitbefore the final stdout/stderr data, confirming that the original implementation resolves too early.Python setup diagnostics
node --test electron/lib/setup-diagnostics.test.jsExisting Electron test suite
npm testThese tests use simulated processes and setup dependencies. The original intermittent Linux AppImage issue was not reproduced manually.
Checklist
Screenshots
Not applicable — this change affects process handling and setup diagnostics rather than the user interface.
Additional notes
The original issue was intermittent and could not be consistently reproduced by QA.
This PR addresses the suspected
exit/closerace condition through a deterministic regression test and adds diagnostic logging to make future Python detection failures easier to investigate.The normal child-process spawning behavior is preserved.