Closed
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) -
@sentry/tracing
Version:
6.4.1
Description
Use '@sentry/tracing' in mini-program environment, when call Sentry.startTransaction
on a page launch at the first time, whould catch the error as below:
TypeError: Cannot read property 'length' of undefined
at MetricsInstrumentation.define.push../node_modules/@sentry/tracing/esm/browser/metrics.js.MetricsInstrumentation.addPerformanceEntries (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:6416)
at common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:6315
at IdleTransaction.define.push../node_modules/@sentry/tracing/esm/idletransaction.js.IdleTransaction.finish (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:7949)
at Function.<anonymous> (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:7932)
at :12319/appservice/<setTimeout callback function>
at VM214 WAService.js:2
at VM214 WAService.js:2(env: macOS,mp,1.05.2105170; lib: 2.17.0)
Check this error in file /node_modules/@sentry/tracing/esm/browser/metrics.js
:
// line 34
if (global.document) {
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (var i = 0; i < document.scripts.length; i++) { // => There are not document.scripts in mini-program
// We go through all scripts on the page and look for 'data-entry'
// We remember the name and measure the time between this script finished loading and
// our mark 'sentry-tracing-init'
if (document.scripts[i].dataset.entry === 'true') {
entryScriptSrc = document.scripts[i].src;
break;
}
}
}
I think should change if (global.document)
to if (global.document && document.scripts != null)
will fix this issue.
Metadata
Metadata
Assignees
Labels
No labels