fix: avoid false Web UI build failures on Windows GBK locales#23850
Merged
Conversation
On Windows systems using a Chinese GBK locale, `hermes update` could misreport the Web UI build as failed even when `npm run build` actually succeeded. The failure was caused by Python decoding captured npm output with the process locale inside a background subprocess reader thread. When npm emitted bytes such as `0x85`, decoding under GBK raised `UnicodeDecodeError`, and Hermes then surfaced a misleading "Web UI build failed" warning. This change makes the npm install/npm ci path and the Web UI build step decode captured output explicitly as UTF-8 with `errors="replace"`. That keeps unexpected bytes from crashing output collection, preserves successful builds, and prevents false negatives during update on Windows. The patch also adds regression tests that verify these subprocess calls always use explicit UTF-8 decoding with replacement semantics.
Contributor
🔎 Lint report:
|
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.
Salvage of #23647 by @VinceZcrikl onto current main.
Summary
hermes updateno longer crashes the Web UI build path withUnicodeDecodeErroron Windows zh_CN (GBK) locales. The npm subprocesses now decode their captured output as UTF-8 witherrors="replace"instead of inheriting the host locale.Root cause:
subprocess.run(text=True)without an explicitencodingfalls back tolocale.getpreferredencoding(). On Chinese Windows that's GBK, which trips on UTF-8 bytes npm emits — Python raisedUnicodeDecodeErrorand the update flow then printed "Web UI build failed" even thoughnpm run buildhad succeeded.Changes
hermes_cli/main.py: addencoding="utf-8", errors="replace"to thenpm ci,npm install, andnpm run buildsubprocess calls in_run_npm_install_deterministicand_build_web_ui.tests/hermes_cli/test_web_ui_build.py: 2 regression tests asserting the kwargs are present.Validation
scripts/run_tests.sh tests/hermes_cli/test_web_ui_build.py— 13/13 passed.Closes #23647.