sentry——sourceMap解析错误解决

5 篇文章 0 订阅
5 篇文章 0 订阅

问题描述:

在local的22.8版本sourcemap执行正常,在远端的22.5版本,sourcemap解析异常。
经过cli工具分析得到错误如下

✔ Fetched data for event: 50c53acf7d4645cab3161fa0f0063e11
✔ Event has release name: testSDK
✔ Event has a valid exception present
✔ Event has a valid stacktrace present
✖ Event exception stacktrace has no in_app frames

问题排查:

  • 首先排查sourcemap上传成功与否:成功
  • 两个server端sourcemap是否一致:一致
  • 两个平台全部删除sourcemap重build:结果一致
  • 参考源码
``in_app``
      Signifies whether this frame is related to the execution of the relevant
      code in this stacktrace. For example, the frames that might power the
      framework's webserver of your app are probably not relevant, however calls
      to the framework's library once you start handling code likely are. See
      notes below on implicit ``in_app`` behavior.


Implicit ``in_app`` behavior exists when the value is not specified on all
    frames within a stacktrace (or collectively within an exception if this is
    part of a chain).
    If **any frame** is marked with ``in_app=True`` or ``in_app=False``:
    - Set ``in_app=False`` where ``in_app is None``
    If **all frames** are marked identical values for ``in_app``:
    - Set ``in_app=False`` on all frames
    .. note:: This interface can be passed as the 'stacktrace' key in addition
              to the full interface path.

参考cli检查源码

fn command_sourcemaps_explain_frame_no_inapp() {
    let _event = mock_endpoint(
        EndpointOptions::new(
            "GET",
            "/api/0/projects/wat-org/wat-project/events/43a57a55cd5a4207ac520c03e1dee1b4/json/",
            200,
        )
        .with_response_file("sourcemaps/get-event-frame-no-inapp.json"),
    );
    register_test("sourcemaps/sourcemaps-explain-frame-no-inapp.trycmd");
}

相关提交记录:
https://github.com/getsentry/sentry-cli/pull/1235/files/13353e7bed33eebb9bd8e9b86d85117a34c39dd3#diff-736417245d392ea89bb574b64b22cc075d41d734657ac55ff173809a1f59ad6e

问题解决

至此初步推断是没有拿到框架信息,猜测以下可能:

  • 文件fetch出错
  • 缺少面包屑
  • 对应不到源框架

签名对应追踪栈frame信息为:

"frames": [
  {
    "filename": "http://localhost:8000/js/index.js",
    "function": "HTMLDivElement.a",
    "in_app": true,
    "lineno": 2,
    "colno": 193993
  },
  {
    "filename": "http://localhost:8000/js/index.js",
    "function": "Ht",
    "in_app": true,
    "lineno": 2,
    "colno": 25040
  },
  {
    "filename": "http://localhost:8000/js/index.js",
    "function": "Wt",
    "in_app": true,
    "lineno": 2,
    "colno": 25256
  }
]

可以看到这里的url地址是

~/js/index.js

本地源文件地址是:

~/dist/js/index.js

这里尝试修改源文件的映射地址

paths: ['./dist/js'],
urlPrefix: '~/js'

这时sourceMap解析可以正常解析

问题结论:

经过验证为框架内路径与线上路径映射问题,最终解决方案路径为更名

至于为什么本地可以解析远端不可以,在对比相关配置后。
发现并无差异,这里推测是22.5到22.8升级时做了更合理化的解析

完整的解决方案分为两种

  • 采用sentry-cli上传,映射更名
sentry-cli releases files test1 upload-sourcemaps --url-prefix "~/js" --validate ./dist/js

采用sentry的webpack插件时配置:

include: [{
  paths: ['./dist/js'],
  urlPrefix: '~/js'
}]

至此,sentry就可以正确寻址到对应源框架了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值