问题描述:

在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就可以正确寻址到对应源框架了。

查看原文