mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN: Remove "js engine" Suffix from Error Stacks (#51913)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51913 Removes the non-standard "js engine" suffix from `Error` stack traces. Changelog: [General][Changed] - Errors will no longer have the "js engine" suffix. Reviewed By: robhogan Differential Revision: D76319439 fbshipit-source-id: e0d8e4f451df7010f48e3076bc244981bf590402
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cbc327ce53
commit
a293925280
@@ -76,9 +76,6 @@ function reportException(
|
||||
message = namePrefix + message;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -175,51 +175,6 @@ function runExceptionsManagerTests() {
|
||||
expect(console.error).toBeCalledWith(formattedMessage);
|
||||
});
|
||||
|
||||
test('adds the JS engine to the message', () => {
|
||||
const error = new Error('Some error happened');
|
||||
// $FlowFixMe[prop-missing]
|
||||
error.jsEngine = 'hermes';
|
||||
// Copy all the data we care about before any possible mutation.
|
||||
const {message, jsEngine} = error;
|
||||
|
||||
ReactFiberErrorDialog.showErrorDialog({
|
||||
...capturedErrorDefaults,
|
||||
error,
|
||||
});
|
||||
|
||||
let exceptionData;
|
||||
|
||||
if (__DEV__) {
|
||||
expect(logBoxAddConsoleLog).not.toBeCalled();
|
||||
expect(nativeReportException).not.toBeCalled();
|
||||
expect(logBoxAddException).toBeCalledTimes(1);
|
||||
exceptionData = logBoxAddException.mock.calls[0][0];
|
||||
} else {
|
||||
expect(logBoxAddConsoleLog).not.toBeCalled();
|
||||
expect(logBoxAddException).not.toBeCalled();
|
||||
expect(nativeReportException).toBeCalledTimes(1);
|
||||
exceptionData = nativeReportException.mock.calls[0][0];
|
||||
}
|
||||
expect(exceptionData.message).toBe(
|
||||
'Error: ' +
|
||||
message +
|
||||
'\n\n' +
|
||||
'This error is located at:' +
|
||||
capturedErrorDefaults.componentStack +
|
||||
', js engine: ' +
|
||||
jsEngine,
|
||||
);
|
||||
expect(console.error).toBeCalledWith(
|
||||
'Error: ' +
|
||||
message +
|
||||
'\n\n' +
|
||||
'This error is located at:' +
|
||||
capturedErrorDefaults.componentStack +
|
||||
', js engine: ' +
|
||||
jsEngine,
|
||||
);
|
||||
});
|
||||
|
||||
test('wraps string in an Error and sends to handleException', () => {
|
||||
const message = 'Some error happened';
|
||||
|
||||
|
||||
@@ -276,12 +276,6 @@ void JsErrorHandler::handleErrorWithCppPipeline(
|
||||
message = *name + ": " + message;
|
||||
}
|
||||
|
||||
auto jsEngineValue = errorObj.getProperty(runtime, "jsEngine");
|
||||
|
||||
if (!isLooselyNull(jsEngineValue)) {
|
||||
message += ", js engine: " + stringifyToCpp(runtime, jsEngineValue);
|
||||
}
|
||||
|
||||
auto extraDataKey = jsi::PropNameID::forUtf8(runtime, "RN$ErrorExtraDataKey");
|
||||
auto extraDataValue = errorObj.getProperty(runtime, extraDataKey);
|
||||
|
||||
@@ -290,6 +284,7 @@ void JsErrorHandler::handleErrorWithCppPipeline(
|
||||
objectAssign(runtime, extraData, extraDataValue.asObject(runtime));
|
||||
}
|
||||
|
||||
auto jsEngineValue = errorObj.getProperty(runtime, "jsEngine");
|
||||
auto isDEV =
|
||||
isTruthy(runtime, runtime.global().getProperty(runtime, "__DEV__"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user