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

Use Metro support for auto-collapsing internal stack frames #25839

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 3 additions & 12 deletions Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

import type {ExtendedError} from './Devtools/parseErrorStack';

const INTERNAL_CALLSITES_REGEX = new RegExp(
[
'/Libraries/Renderer/oss/ReactNativeRenderer-dev\\.js$',
'/Libraries/BatchedBridge/MessageQueue\\.js$',
].join('|'),
);

/**
* Handles the developer-visible aspect of errors and exceptions
*/
Expand Down Expand Up @@ -50,14 +43,12 @@ function reportException(e: ExtendedError, isFatal: boolean) {
symbolicateStackTrace(stack)
.then(prettyStack => {
if (prettyStack) {
const stackWithoutInternalCallsites = prettyStack.filter(
frame =>
frame.file &&
frame.file.match(INTERNAL_CALLSITES_REGEX) === null,
const stackWithoutCollapsedFrames = prettyStack.filter(
frame => !frame.collapse,
);
NativeExceptionsManager.updateExceptionMessage(
message,
stackWithoutInternalCallsites,
stackWithoutCollapsedFrames,
currentExceptionID,
);
} else {
Expand Down
1 change: 1 addition & 0 deletions Libraries/Core/NativeExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type StackFrame = {|
file: string,
lineNumber: number,
methodName: string,
collapse?: boolean,
|};

export type ExceptionData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ namespace JS {
NSString *file() const;
double lineNumber() const;
NSString *methodName() const;
folly::Optional<bool> collapse() const;

StackFrame(NSDictionary *const v) : _v(v) {}
private:
Expand Down Expand Up @@ -2649,6 +2650,11 @@ inline NSString *JS::NativeExceptionsManager::StackFrame::methodName() const
id const p = _v[@"methodName"];
return RCTBridgingToString(p);
}
inline folly::Optional<bool> JS::NativeExceptionsManager::StackFrame::collapse() const
{
id const p = _v[@"collapse"];
return RCTBridgingToOptionalBool(p);
}

inline NSString *JS::NativeExceptionsManager::ExceptionData::message() const
{
Expand Down