Pass native stack to ExceptionManager (#37995)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37995

We now have native stack symbols (since D45182122) for TurboModule exceptions, so report those to ExceptionManager so they can end up in the crash reporting pipeline. It will likely not get symbolicated properly yet, but at least we'll have some metadata.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D46893131

fbshipit-source-id: 2b2713ed3af9a366cc43f8ceaef36000834310c7
This commit is contained in:
Pieter De Baets
2023-06-22 09:13:25 -07:00
committed by Facebook GitHub Bot
parent ede86a3c0c
commit 1001cf653c
2 changed files with 26 additions and 6 deletions
+14 -6
View File
@@ -78,6 +78,19 @@ function reportException(
message =
e.jsEngine == null ? message : `${message}, js engine: ${e.jsEngine}`;
// $FlowFixMe[unclear-type]
const extraData: Object = {
// $FlowFixMe[incompatible-use] we can't define a type with a Symbol-keyed field in flow
...e[decoratedExtraDataKey],
jsEngine: e.jsEngine,
rawStack: e.stack,
};
if (e.cause != null && typeof e.cause === 'object') {
extraData.stackSymbols = e.cause.stackSymbols;
extraData.stackReturnAddresses = e.cause.stackReturnAddresses;
extraData.stackElements = e.cause.stackElements;
}
const data = preprocessException({
message,
originalMessage: message === originalMessage ? null : originalMessage,
@@ -87,12 +100,7 @@ function reportException(
stack,
id: currentExceptionID,
isFatal,
extraData: {
// $FlowFixMe[incompatible-use] we can't define a type with a Symbol-keyed field in flow
...e[decoratedExtraDataKey],
jsEngine: e.jsEngine,
rawStack: e.stack,
},
extraData,
});
if (reportToConsole) {
+12
View File
@@ -18,4 +18,16 @@ export type ExtendedError = Error &
// Note: A field keyed by the Symbol ExceptionsManager.decoratedExtraDataKey is also read from ExtendedErrors.
// This field isn't documented in the types as Flow does not support this usecase, but it's effectively:
// [decoratedExtraDataKey]?: {[string]: mixed},
// Included for native errors
cause?: {
name: string,
message: string,
// $FlowFixMe[unclear-type]
stackElements?: $ReadOnlyArray<Object>,
// $FlowFixMe[unclear-type]
stackSymbols?: $ReadOnlyArray<Object>,
// $FlowFixMe[unclear-type]
stackReturnAddresses?: $ReadOnlyArray<Object>,
},
};