Skip to content

Wrong stacktrace #1540

@mehulmpt

Description

@mehulmpt

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

2.6.4

Description

This is my raven configuration in index.ts

import * as Raven from 'raven'

Raven.config('<dsn link>', {
	release: require('./package.json').version,
	captureUnhandledRejections: true,
	sendTimeout: process.env.NODE_ENV === 'production' ? 2 : 5,
	dataCallback: function (data) {

		const stacktrace = data.exception && data.exception[0].stacktrace

		console.log(stacktrace.frames)

		if (stacktrace && stacktrace.frames) {
			stacktrace.frames.forEach(function(frame) {
			
			if (frame.filename.startsWith('/')) {
				frame.filename = 'app:///' + path.basename(frame.filename)
			}

			})
		}

		return data
	}
}).install()

and here's my webpack config for server:

{
	entry: {
		server: path.resolve(__dirname, 'index.ts')
	},
	externals: [nodeExternals()],
	devtool: 'source-map',
	target: 'node',
	output: {
		path: path.resolve(__dirname),
		filename: './server/server.js',
		libraryTarget: 'commonjs',
		publicPath: path.resolve(__dirname)
	},
	node: {
		__dirname: true
	},
	module: {
		rules: [
			{
			  test: /\.tsx?$/,
			  use: 'ts-loader',
			  exclude: /node_modules/
			}
		  ]
	},
	plugins: [
		new SentryPlugin({
			release: require('./package.json').version,
			include: './server', // uploads only server.js and server.map.js files
			ignore: ['node_modules', 'webpack.config.js'],
			debug: true,
		})
	]
}

It works fine, but if I throw even a very simple error, here's the filenames in stacktrace inside the dataCallback function handler:

0:"internal/process/next_tick.js"
1:"internal/process/promises.js"
2:"events.js"
3:"events.js"
4:"/Users/dev/../../../../folder path../node_modules/raven/lib/client.js"
5:"/Users/dev/../../../../folder path../node_modules/raven/lib/client.js"

Which is obviously wrong as error was thrown in server.js file served through node server/server.js command. This then is uploaded to sentry which obviously throws this warning:

Source code was not found for app:///client.js

What am I doing wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions