哨兵源地图未在Node.js(express.js)的异常报告中显示代码

时间:2019-12-13 17:22:38

标签: node.js express webpack source-maps sentry

我们有一个集成了Sentry的Node.js项目,最近我们决定增加对源地图的支持。我们已经发布了功能正常工作,并且使用正确的代码行将异常报告给Sentry,但是没有例外代码摘录。

以下是异常报告的样子: enter image description here

这是版本概述: enter image description here

以下是发布工件: enter image description here

我们使用哨兵webpack插件(https://www.npmjs.com/package/@sentry/webpack-plugin),其配置如下:

    new SentryWebpackPlugin({
      release: process.env.SENTRY_RELEASE,
      include: './build',
      ignore: ['node_modules', 'webpack.config.js'],
      setCommits: {
        repo: 'ORG/REPO_NAME',
        auto: true
      },
      configFile: 'sentryconfig.properties'
    })

并使用以下代码初始化Sentry:

import * as Sentry from '@sentry/node';
import { RewriteFrames, Dedupe, Transaction } from '@sentry/integrations';

import config from '../config';

  Sentry.init({
    dsn: config.sentry.dsn,
    release: process.env.SENTRY_RELEASE,
    environment: config.environment,
    integrations: [
      ...Sentry.defaultIntegrations,
      new RewriteFrames({ root: __dirname }),
      new Dedupe(),
      new Transaction()
    ],
    maxBreadcrumbs: 50,
    attachStacktrace: true
  });

然后以这种方式抛出测试错误:

server.use(Sentry.Handlers.requestHandler());
server.get('/generate/error', () => {
  throw Error('server test error for sentry');
});
server.use(Sentry.Handlers.errorHandler());

此设置有什么问题?是否可以在Sentry中发生错误的地方显示代码?

0 个答案:

没有答案