bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

Source mapping failed: A source map could not be applied #420

Closed john1jan closed 4 years ago

john1jan commented 4 years ago

Description

Source mapping failed: A source map could not be applied Hide Details A source map was found but could not be applied because it doesn't match the code. Ensure that the source map is correctly generated and matches the version of your code. (Note that events are not reprocessed after source maps are uploaded.)

Getting this issue even after uploaded valid source map

Issue

Environment

Library versions:

yarn list v1.13.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ bugsnag-react-native@2.22.2
└─ react-native@0.59.10

Example code snippet

import Config from "react-native-config";
import VersionNumber from 'react-native-version-number';

import { Client, Configuration } from "bugsnag-react-native";
let bugsnag = null;

export function configure() {
    const configuration = new Configuration()
    configuration.apiKey = "API-KEY";
    configuration.autoCaptureSessions = true;
    configuration.appVersion = VersionNumber.appVersion
    configuration.handlePromiseRejections = true
    configuration.releaseStage = Config.DEBUG ? "development" : Config.FLAVOUR;
    configuration.codeBundleId = VersionNumber.appVersion
    bugsnag = new Client(configuration);
}

Build command

react-native bundle --platform android --dev false
 --entry-file index.android.js 
 --bundle-output index.android.bundle 
 --assets-dest android/app/src/main/res  
 --sourcemap-output index.android.sourcemap.map

Upload source map using bugsnag react native plugin

bugsnag-sourcemaps upload \
    --api-key API-KEY \
    --app-version 12.1 \
    --code-bundle-id 12.1 \
    --app-version-code 131 \
    --minified-file index.android.bundle \
    --source-map index.android.sourcemap.map \
    --minified-url index.android.bundle \
    --upload-sources \
    --add-wildcard-prefix \
    --overwrite 
Screenshot 2019-11-06 at 12 51 52 PM

We are not using codepush and i am setting app version in codeBundleId.

mattdyoung commented 4 years ago

Hi @john1jan

I assume you've already seen our response on the related support ticket you raised.

It looks as though you've enabled RAM bundles in React Native: https://facebook.github.io/react-native/docs/performance#ram-bundles-inline-requires

You can see this as your unmapped stacktraces are showing e.g. 2647.js rather than index.android.bundle.

These are supported by Bugsnag but you'll need to follow the latest instructions here: https://docs.bugsnag.com/platforms/react-native/react-native/showing-full-stacktraces/#generating-source-maps

It's essential that you use the react-native ram-bundle command instead of react-native bundle when generating the source map, and that you upload to the newer https://upload.bugsnag.com/react-native-source-map API end-point.

john1jan commented 4 years ago

Thanks it worked, after ram-bundle