Skip to content

Commit

Permalink
Don't hard crash if you get a null stack trace in Android
Browse files Browse the repository at this point in the history
Summary: If stacktrace-parser can't parse a stack trace, it'll return null. This can cause us to accidentally enter a crash loop where whenever you start your app, you load the last JS bundle you had, get a crash, and then hard crash trying to print the stack trace.

Reviewed By: frantic

Differential Revision: D3528141

fbshipit-source-id: 1146f43bc40492bfa79b6a1c0f81092383896164
  • Loading branch information
astreet authored and Facebook Github Bot 4 committed Jul 7, 2016
1 parent 2537157 commit b5c3550
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package com.facebook.react.devsupport;

import javax.annotation.Nullable;

import java.io.File;

import com.facebook.react.bridge.ReadableArray;
Expand Down Expand Up @@ -91,9 +93,10 @@ public String getFileName() {
* Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of
* {@link StackFrame}s.
*/
public static StackFrame[] convertJsStackTrace(ReadableArray stack) {
StackFrame[] result = new StackFrame[stack.size()];
for (int i = 0; i < stack.size(); i++) {
public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) {
int size = stack != null ? stack.size() : 0;
StackFrame[] result = new StackFrame[size];
for (int i = 0; i < size; i++) {
ReadableMap frame = stack.getMap(i);
String methodName = frame.getString("methodName");
String fileName = frame.getString("file");
Expand Down

0 comments on commit b5c3550

Please sign in to comment.