question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Followed source map instructions, but line numbers are wrong, etc

See original GitHub issue

Package + Version

  • @sentry/node - 5.18.1
  • @sentry/integrations - 5.18.1
  • @sentry/webpack-plugin - 1.11.1

Description

I’ve followed the instructions on source maps to the best of my knowledge. I’m trying this out with a Serverless Framework setup.

It’s quite an improvement over how reporting looked before I followed the steps, but the line number is totally wrong and the module name is missing. There’s also still remnants of webpack variable names.

https://sentry.io/organizations/reelcrafter/issues/1749922899/?project=5298557

Screen Shot 2020-06-27 at 6 19 00 PM

webpack.config.js

const path = require("path");
// eslint-disable-next-line import/no-unresolved
const slsw = require("serverless-webpack");
const SentryPlugin = require("@sentry/webpack-plugin");

module.exports = {
  entry: slsw.lib.entries,
  devtool: "source-map",
  output: {
    libraryTarget: "commonjs",
    filename: "[name].js",
    path: path.join(__dirname, ".webpack"),
  },
  mode: "development",
  target: "node",
  module: {
    rules: [
      {
        test: /\.js$/, // include .js files
        enforce: "pre", // preload the jshint loader
        exclude: /node_modules/, // exclude any and all files in the node_modules folder
        include: __dirname,
        use: [
          {
            loader: "babel-loader",
          },
        ],
      },
    ],
  },
  plugins: [
    new SentryPlugin({
      release: process.env.RELEASE,
      include: "./.webpack",
    }),
  ],
};

test.js

import * as Sentry from "@sentry/node";
import { RewriteFrames } from "@sentry/integrations";

Sentry.init({
  dsn: "https://xx",
  release: process.env.RELEASE,
  integrations: [new RewriteFrames()],
});

/**
 ...
*/

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
kamilogorekcommented, Jul 10, 2020

WARNING in configuration. The ‘mode’ option has not been set, webpack will fallback to ‘production’ for this value. Set ‘mode’ option to ‘development’ or ‘production’ to enable defaults for each environment.

😶

I found the main issue. It’s TerserPlugin messing around with the source code.

optimization: {
  minimize: false,
},

Add this to your webpack config and you should be good no matter what mode is set! (this is the only change I did base on your current repo state).

You can play around with TerserPlugin default options to find which exactly is the culprit if you want to use it nonetheless - https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions

BTW, I appreciate all your time and help! Don’t worry, I’m a paid Sentry customer. 😆

Anytime, I’m curious myself what’s going in here 😄

1reaction
ipetrinicommented, Sep 17, 2020

For anyone who might still have problems with the source map line numbers while using Terser plugin, I could get it working properly by disabling the following compress options in terserOptions:

compress: {
  conditionals: false,
  sequences: false
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect line numbers - sourcemaps, Webpack 2 Typescript
I have tried setting devtool to the following different options: //https://webpack.js.org/configuration/devtool/ //devtool: 'eval', //eval vert ...
Read more >
Source map line numbers mismatch (Angular) - Elastic Discuss
I am using Angular 9 and elastic/apm-rum-angular version 1.1.6. I uploaded the source maps generated by running "ng build --source-map".
Read more >
Debug Node.js Apps using Visual Studio Code
The JavaScript debugger of VS Code supports source maps that help debugging of transpiled languages, for example, TypeScript or minified/uglified JavaScript.
Read more >
Is it safe to ship JavaScript Source maps to production?
With source maps, you can click on a certain line and column number in your generated JavaScript, and that will do a lookup...
Read more >
Vue + TypeScript & Debuggers - ckh|Consulting
Restart your app, launch Chrome in debug mode again (through VS Code's debug screen), and navigate to the App.vue Source Map. You will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found