3

I am using bugsnag for error reporting. To show stacktrace of errors bugsnag needs sourcemaps, which I am trying to upload to bugsnag using this documentation: Uploading source map github: bugsnag sourcemaps

I have used upload API of bugsnag to upload sourcemaps on bugsnags for my react app and then I am deleting the sourcemaps from my host. After doing this when I checked bugsnag sourcemaps setting it is showing me minified files URLs in "Source URL" column.

bugsnag sourcemaps

I am getting a message:

Source mapping failed: A source map could not be found Could not find original source file and line numbers because the source map could not be downloaded from https://hostname/minifiedFileName.js.map. Ensure that your source map is accessible from our servers or upload them to us. (Note that events are not reprocessed after source maps are uploaded.)

This is because after uploading I am deleting sourcemaps from build. I am assuming with upload API sourcemaps are uploaded to bugsnag and we don't need to keep sourcemaps at our host.

I am not understanding what step am I missing in uploading sourcemaps to bugsnag.

I have created a file process-bugsnag-sourcemaps.js

const { upload } = require('bugsnag-sourcemaps');
const reportBuild = require('bugsnag-build-reporter');
const glob = require('glob');
const fs = require('fs');

function uploadSourceMap(sourceMap) {
  const minifiedFile = sourceMap.replace('.map', '');
  const minifiedFileServerPath = `${minifiedFile.split('/')[2]}/${
    minifiedFile.split('/')[3]
  }/${minifiedFile.split('/')[4]}`;

  return upload({
    apiKey: config.get('BUGSNAG_API_KEY'),
    appVersion,
    overwrite: true,
    minifiedUrl: `${config.get('STATIC_PATH')}${minifiedFileServerPath}`,
    sourceMap,
    minifiedFile,
    projectRoot: __dirname,
    uploadSources: true,
  });
}

/**
 * Find, upload and delete Source Maps
 */
function processSourceMaps() {
  findSourceMaps((error, files) =>
    Promise.all(files.map(uploadSourceMap))
      .then(() => {
        deleteFiles(files);
        notifyRelease();
      })
      .catch(e => {
        console.log(e);
      })
  );
}
processSourceMaps();

This is the Article from where I referenced code to write upload function: Upload Create React App source maps to Bugsnag for easier debugging and delete them afterwards for security

Why sourcemaps are not uploaded on bugsnag and why bugsnag is trying to access sourcemaps from my minfifiedUrl host I specified in upload function?

It would be great if someone point out which step am I missing?

I have added this issue on github repository

Always_a_learner
  • 4,585
  • 13
  • 63
  • 112

0 Answers0