Repository navigation
Skip -base-bytecode when Hermes bytecode versions differ - #57
Merged
Merged
Conversation
hermesc aborts with "Wrong bytecode version. Expected N but got M" when the base release bundle was compiled by a different Hermes bytecode version (e.g. v96 base vs v98 compiler after a React Native upgrade). Read the version from the base bundle's HBC header and from `hermesc -version`, and drop -base-bytecode with a warning when they differ, cannot be detected, or the base is not Hermes bytecode. Also stop the hermes and compose-source-maps close handlers after rejecting, reject on hermes spawn errors, and time out the version probe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compile an empty input to stdout with `hermesc -emit-binary -` and read the version from the emitted header instead of parsing `hermesc -version` text, so the base bundle and the compiler are checked the same way. Shorten the version mismatch warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ashirman
approved these changes
Oct 8, 2026
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
A customer's
release-reactfailed with:When Hermes is enabled, the CLI downloads the base release bundle for the deployment and app version and passes it to the local compiler as
hermesc -base-bytecode <file>.hermescrefuses any base whose bytecode version differs from its own. In this case the base was v96 and the local compiler produces v98, after a React Native / Hermes upgrade.Fix
static_h(Hermes V1), starts the file withuint64 magic (0x1F1903C103BC1FC6)followed byuint32 version, little-endian. This is the same field the Hermes loader checks when it raises "Wrong bytecode version".hermesc -version, which printsHBC bytecode version: N. Old compilers print the same line.-base-bytecodeonly when the two versions match. When they differ, when the compiler version can't be detected, or when the base isn't Hermes bytecode, drop the flag and log why. The base only makes the output smaller to diff, so the release still works without it.The mismatch warning also says that apps built with the older bytecode can't run the new update. If React Native was upgraded, the customer needs a new store build.
Also fixed (found in review)
hermesexit handler now stops after reporting a failure, so a failed compile no longer copies its partial.hbcover the JS bundle.hermescpath now fails the release with an error instead of crashing the CLI.hermesc -versionnow has a 30-second timeout.Open question
On a version mismatch the release still uploads, with a warning. We could instead fail the release unless
--forceis passed, since devices on the older binary can't load the bundle.Testing
test/hermes-bytecode.tscovers reading the header, plain JS and truncated files, parsing the-versionoutput, and keeping or skipping the base.hermesc(v96): compiling a file and reading its header gives 96, and parsing-versiongives 96.tscpasses, and all 26 tests pass (hermes-bytecode,release-size-flow,release-size-utils,source-map-utils).🤖 Generated with Claude Code