facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.67k stars 619 forks source link

Invalid Source map #1457

Closed evolvingkid closed 1 month ago

evolvingkid commented 1 month ago

Bug Description

Error code is not connecting with the source map from IOS.

Screenshot 2024-07-12 at 11 47 58 AM

We use export SOURCEMAP_FILE="ios/main.jsbundle.map"; in the react native code and image to get the source mapping from the build generated from Xcode.

export SOURCEMAP_FILE="ios/main.jsbundle.map";
export PATH=/opt/homebrew/bin:$PATH
set -e

export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh

Code in the Bundle React Native code and images in xcode.

This will generate a bundle.map file in the IOS directory. But when Bugsnag tries to get the error line it will fail.

We run a custom code to check if this specific error is coming from source map by running the below script.

const fs = require("fs");
const sourceMap = require("source-map");

const mapPath = "./main.jsbundle.map";

const minifiedLocation = { line: 1, column: 3497710 };
const sourceMapContent = fs.readFileSync(mapPath, "utf8");

sourceMap.SourceMapConsumer.with(sourceMapContent, null, (consumer) => {
  const originalPosition = consumer.originalPositionFor(minifiedLocation);
  console.log("mapped location", originalPosition);
});

This will output null as the result. mapped location { source: null, line: null, column: null, name: null }

Hermes git revision (if applicable): React Native version: ^0.72.3 OS:

Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): IOS iphone

Steps To Reproduce

  1. Create a source map from Xcode.

code example:

The Expected Behavior

The source map should be pointing toward the error in the onPressRoundedNextLogin function.


  const onPressRoundedNextLogin = async (text) => {
    Bugsnag.notify(new Error('Test error'));
    }
tmikov commented 1 month ago

I am sorry, I understand that you are having a problem, but your description is referring to libraries and tools that are not part of Hermes. For example, I don't know what Bugsnag is, I don't know what "Create a source map from Xcode" means. Similarly, react-native/scripts/react-native-xcode.sh is not part of Hermes and I have no idea what it does.

Can you provide a minimal isolated reproduction that demonstrates a specific problem in Hermes?