Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Strip a bogus function name suffix from Hermes frames #752

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/js/integrations/debugsymbolicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export class DebugSymbolicator implements Integration {
jsEngine: reactError.jsEngine
};

if (__DEV__) {
await self._symbolicate(event, stack);
}
await self._symbolicate(event, stack);
if (reactError.jsEngine === "hermes") {
const convertedFrames = await this._convertReactNativeFramesToSentryFrames(
stack
Expand Down Expand Up @@ -123,9 +121,7 @@ export class DebugSymbolicator implements Integration {
): Promise<StackFrame[]> {
let getDevServer: any;
try {
if (__DEV__) {
getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
}
getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
} catch (_oO) {
// We can't load devserver URL
}
Expand All @@ -151,7 +147,20 @@ export class DebugSymbolicator implements Integration {
platform: inApp ? "javascript" : "node" // :HACK
};

if (inApp && __DEV__) {
// The upstream `[email protected]` delegates parsing of stacks to `stacktrace-parser`, which is buggy and
// leaves a trailing `(address at` in the function name.
// `[email protected]` seems to have custom logic to parse hermes frames specially.
// Anyway, all we do here is throw away the bogus suffix.
if (newFrame.function) {
const addressAtPos = newFrame.function.indexOf("(address at");
if (addressAtPos >= 0) {
newFrame.function = newFrame.function
.substr(0, addressAtPos)
.trim();
}
}

if (inApp) {
// tslint:disable-next-line: no-unsafe-any
await this._addSourceContext(newFrame, getDevServer);
}
Expand Down
10 changes: 7 additions & 3 deletions src/js/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export function init(
new Integrations.Breadcrumbs({
console: false, // If this in enabled it causes problems to native calls on >= RN 0.60
fetch: false
}),
new DebugSymbolicator(),
})
];
if (__DEV__) {
options.defaultIntegrations.push(new DebugSymbolicator());
}
options.defaultIntegrations.push(
new RewriteFrames({
iteratee: (frame: StackFrame) => {
if (frame.filename) {
Expand All @@ -63,7 +67,7 @@ export function init(
}
}),
new DeviceContext()
];
);
}
if (options.enableNative === undefined) {
options.enableNative = true;
Expand Down