Skip to content

Commit 9a54650

Browse files
gillpeacegoodkamilogorek
authored andcommitted
Allow sentry to work with v8 on react-native (getsentry#2397)
* Allow sentry to work with v8 on react-native * Add a unit test for react-native-v8
1 parent 5b4830e commit 9a54650

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/browser/src/tracekit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface StackTrace {
4242
const UNKNOWN_FUNCTION = '?';
4343

4444
// Chromium based browsers: Chrome, Brave, new Opera, new Edge
45-
const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|[-a-z]+:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
45+
const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
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.

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

+25
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@ describe('Tracekit - Custom Tests', () => {
2424
]);
2525
});
2626

27+
it('should parse exceptions for react-native-v8', () => {
28+
const REACT_NATIVE_V8_EXCEPTION = {
29+
message: 'Manually triggered crash to test Sentry reporting',
30+
name: 'Error',
31+
stack: `Error: Manually triggered crash to test Sentry reporting
32+
at Object.onPress(index.android.bundle:2342:3773)
33+
at s.touchableHandlePress(index.android.bundle:214:2048)
34+
at s._performSideEffectsForTransition(index.android.bundle:198:9608)
35+
at s._receiveSignal(index.android.bundle:198:8309)
36+
at s.touchableHandleResponderRelease(index.android.bundle:198:5615)
37+
at Object.y(index.android.bundle:93:571)
38+
at P(index.android.bundle:93:714)`,
39+
};
40+
const stacktrace = computeStackTrace(REACT_NATIVE_V8_EXCEPTION);
41+
expect(stacktrace.stack).deep.equal([
42+
{ url: 'index.android.bundle', func: 'Object.onPress', args: [], line: 2342, column: 3773 },
43+
{ url: 'index.android.bundle', func: 's.touchableHandlePress', args: [], line: 214, column: 2048 },
44+
{ url: 'index.android.bundle', func: 's._performSideEffectsForTransition', args: [], line: 198, column: 9608 },
45+
{ url: 'index.android.bundle', func: 's._receiveSignal', args: [], line: 198, column: 8309 },
46+
{ url: 'index.android.bundle', func: 's.touchableHandleResponderRelease', args: [], line: 198, column: 5615 },
47+
{ url: 'index.android.bundle', func: 'Object.y', args: [], line: 93, column: 571 },
48+
{ url: 'index.android.bundle', func: 'P', args: [], line: 93, column: 714 },
49+
]);
50+
});
51+
2752
describe('should parse exceptions with native code frames', () => {
2853
it('in Chrome 73', () => {
2954
const CHROME73_NATIVE_CODE_EXCEPTION = {

0 commit comments

Comments
 (0)