Use Metro support for auto-collapsing internal stack frames (#25839)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/25839 Changes `ExceptionsManager` to respect the `collapse` field in each symbolicated stack frame returned from Metro. This is ultimately driven by a Metro config option (which will have a default set in https://github.com/react-native-community/cli/pull/596). This is part of a redesign of work done originally in https://github.com/facebook/react-native/pull/24662. Reviewed By: cpojer Differential Revision: D16500277 fbshipit-source-id: b0b035618cb000935a555796523637b5f0a688d3
This commit is contained in:
Родитель
6f4c4b59d1
Коммит
77125a1ac3
|
@ -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
|
||||
*/
|
||||
|
@ -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 {
|
||||
|
|
|
@ -18,6 +18,7 @@ export type StackFrame = {|
|
|||
file: string,
|
||||
lineNumber: number,
|
||||
methodName: string,
|
||||
collapse?: boolean,
|
||||
|};
|
||||
|
||||
export type ExceptionData = {
|
||||
|
|
|
@ -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:
|
||||
|
@ -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
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче