Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hermes error: Error encoding bytecode #3143

Open
2 of 5 tasks
yogeshpaliyal opened this issue May 14, 2024 · 8 comments
Open
2 of 5 tasks

Hermes error: Error encoding bytecode #3143

yogeshpaliyal opened this issue May 14, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@yogeshpaliyal
Copy link

yogeshpaliyal commented May 14, 2024

What happened?

On hermes command getting the error, without any specific error message.

error: Error encoding bytecode <Printing the whole js bundle>

I am trying to create bundle for React-Native, earlier we were using the metro bundler, but now we want to add tree-shaking capability to it, so we are trying rnx-kit.

Our react native version: 0.72.7

Trying to create bundle independently without gradle.

Affected Package

@rnx-kit/metro-serializer-esbuild

Version

0.1.33

Which platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows

System Information

System:
  OS: macOS 14.4.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 340.58 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 16.15.1
    path: ~/.nvm/versions/node/v16.15.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v16.15.1/bin/yarn
  npm:
    version: 8.12.1
    path: ~/.nvm/versions/node/v16.15.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.11
    path: /Users/<username>/.jenv/shims/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.7
    wanted: 0.72.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

babel.config.js

presets: [["module:metro-react-native-babel-preset", { disableImportExportTransform: true }]]

metro.config.js

const { makeMetroConfig } = require('@rnx-kit/metro-config');
const { MetroSerializer, esbuildTransformerConfig } = require('@rnx-kit/metro-serializer-esbuild');

module.exports = makeMetroConfig({
    serializer: {
        customSerializer: MetroSerializer([], {
            logLevel: 'verbose',
            target: 'hermes0.11.0'
        })
    },
    transformer: esbuildTransformerConfig,
});

Note: Tried default target as well.

Using command to create js bundle.

react-native bundle --platform android --dev false --entry-file index.js --bundle-output bundle.js --sourcemap-output bundle.map --reset-cache

Command to run hermes:

node_modules/react-native/sdks/hermesc/osx-bin/hermesc -O -w -g -emit-binary -output-source-map -out bundle.hbc bundle.js

Code of Conduct

  • I agree to follow this project's Code of Conduct
@yogeshpaliyal yogeshpaliyal added the bug Something isn't working label May 14, 2024
@yogeshpaliyal
Copy link
Author

yogeshpaliyal commented May 14, 2024

@tido64
Can this be because of different version of hermes in react-native and esbuild.

@tido64
Copy link
Member

tido64 commented May 14, 2024

  • Which tool is outputting the error?
  • What else is output besides Error encoding bytecode?
  • Does the bundle work without the hermesc step?

@yogeshpaliyal
Copy link
Author

  1. I am using a normal terminal.
  2. It is printing the whole js bundle after the error.
  3. I haven't tried running this and will try this and update on this.

@tido64
Copy link
Member

tido64 commented May 14, 2024

  1. I am using a normal terminal.

Sorry, what I meant to say is which "command". Is hermesc outputting this? Can you get more logging enabled? This is not much to go on.

@yogeshpaliyal
Copy link
Author

  1. I am using a normal terminal.

Sorry, what I meant to say is which "command". Is hermesc outputting this? Can you get more logging enabled? This is not much to go on.

Yes hermesc is giving the error.

@yogeshpaliyal
Copy link
Author

Not able to start logging in hermesc is there any flag to enable logging. I was not able to find a flag to enable logging.

@yogeshpaliyal
Copy link
Author

  1. No the bundle is not working without hermes as well, getting this logs repetitive and then app crashes.
    @set_metadata: update dataspace from GM (0x00000000 -> 0x0801000)

@tido64
Copy link
Member

tido64 commented May 15, 2024

Can you create a minimal repro? This is unfortunately not enough information for us to start an investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants