Skip to content

Commit 668f44f

Browse files
authored
fix(tracekit): Handle expo file dir stack frames (#3070)
1 parent 5db4202 commit 668f44f

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

packages/browser/src/tracekit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|addre
4646
// gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4747
// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4848
// We need this specific case for now because we want no other regex to match.
49-
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i;
49+
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
5050
const winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
5151
const geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
5252
const chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;

packages/browser/test/unit/tracekit/custom.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,60 @@ describe('Tracekit - Custom Tests', () => {
4949
]);
5050
});
5151

52+
it('should parse exceptions for react-native Expo bundles', () => {
53+
const REACT_NATIVE_EXPO_EXCEPTION = {
54+
message: 'Test Error Expo',
55+
name: 'Error',
56+
stack: `onPress@/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3:595:658
57+
value@/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3:221:7656
58+
onResponderRelease@/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3:221:5666
59+
p@/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3:96:385
60+
forEach@[native code]`,
61+
};
62+
const stacktrace = computeStackTrace(REACT_NATIVE_EXPO_EXCEPTION);
63+
expect(stacktrace.stack).deep.equal([
64+
{
65+
url:
66+
'/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3',
67+
func: 'onPress',
68+
args: [],
69+
line: 595,
70+
column: 658,
71+
},
72+
{
73+
url:
74+
'/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3',
75+
func: 'value',
76+
args: [],
77+
line: 221,
78+
column: 7656,
79+
},
80+
{
81+
url:
82+
'/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3',
83+
func: 'onResponderRelease',
84+
args: [],
85+
line: 221,
86+
column: 5666,
87+
},
88+
{
89+
url:
90+
'/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3',
91+
func: 'p',
92+
args: [],
93+
line: 96,
94+
column: 385,
95+
},
96+
{
97+
url: '[native code]',
98+
func: 'forEach',
99+
args: [],
100+
line: null,
101+
column: null,
102+
},
103+
]);
104+
});
105+
52106
describe('should parse exceptions with native code frames', () => {
53107
it('in Chrome 73', () => {
54108
const CHROME73_NATIVE_CODE_EXCEPTION = {

0 commit comments

Comments
 (0)