mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Update the "nativeStackAndroid" (#25014)
Summary: Update the "nativeStackAndroid" frame limit to 50 and include the class name on the "nativeStackAndroid". nativeStackAndroid only contains up to 10 lines of stack traces. This is due to the "ERROR_STACK_FRAME_LIMIT" set to 10 on https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java.  nativeStackAndroid should contain a more reasonable number of the native stack traces. (nativeStackIOS includes all of them). another improvement could be adding the "declaringClass" on top of the "methodName", "LineNumber", and "file" on the stack trace frameMap.  ## Changelog [Android] [Added] - Update the "nativeStackAndroid" frame limit to 50 and include class name Pull Request resolved: https://github.com/facebook/react-native/pull/25014 Differential Revision: D15503022 Pulled By: cpojer fbshipit-source-id: 6f1bc25ea739715d0e7589d430bf9cf72da305b2
This commit is contained in:
committed by
Facebook Github Bot
parent
651cc2613f
commit
206bb6d3b9
@@ -20,7 +20,7 @@ import javax.annotation.Nullable;
|
||||
public class PromiseImpl implements Promise {
|
||||
// Number of stack frames to parse and return to mReject.invoke
|
||||
// for ERROR_MAP_KEY_NATIVE_STACK
|
||||
private static final int ERROR_STACK_FRAME_LIMIT = 10;
|
||||
private static final int ERROR_STACK_FRAME_LIMIT = 50;
|
||||
|
||||
private static final String ERROR_DEFAULT_CODE = "EUNSPECIFIED";
|
||||
private static final String ERROR_DEFAULT_MESSAGE = "Error not specified.";
|
||||
@@ -32,6 +32,7 @@ public class PromiseImpl implements Promise {
|
||||
private static final String ERROR_MAP_KEY_NATIVE_STACK = "nativeStackAndroid";
|
||||
|
||||
// Keys for ERROR_MAP_KEY_NATIVE_STACK's StackFrame maps
|
||||
private static final String STACK_FRAME_KEY_CLASS = "class";
|
||||
private static final String STACK_FRAME_KEY_FILE = "file";
|
||||
private static final String STACK_FRAME_KEY_LINE_NUMBER = "lineNumber";
|
||||
private static final String STACK_FRAME_KEY_METHOD_NAME = "methodName";
|
||||
@@ -218,6 +219,7 @@ public class PromiseImpl implements Promise {
|
||||
StackTraceElement frame = stackTrace[i];
|
||||
WritableMap frameMap = new WritableNativeMap();
|
||||
// NOTE: no column number exists StackTraceElement
|
||||
frameMap.putString(STACK_FRAME_KEY_CLASS, frame.getClassName());
|
||||
frameMap.putString(STACK_FRAME_KEY_FILE, frame.getFileName());
|
||||
frameMap.putInt(STACK_FRAME_KEY_LINE_NUMBER, frame.getLineNumber());
|
||||
frameMap.putString(STACK_FRAME_KEY_METHOD_NAME, frame.getMethodName());
|
||||
|
||||
Reference in New Issue
Block a user