Permalink
Browse files

Protect against fatal YellowBox error when stack frame has no file

Summary:
Motivation: When viewing a stack trace in YellowBox where one or more of the stack frames has no `file`, JS will encounter the fatal error `null is not an object (evaluating 'file.split')`. This can happen, for example, when running a bundle for which no source maps were generated.
Closes #13512

Differential Revision: D4896480

Pulled By: javache

fbshipit-source-id: 202c793a47abb83a4700a5778a92b0b5828b01a3
  • Loading branch information...
terribleben authored and ide committed Apr 18, 2017
1 parent 7c90b06 commit 106ad8592c1f7e88ae42a4045f772aba0db2c7b7
Showing with 7 additions and 2 deletions.
  1. +7 −2 Libraries/ReactNative/YellowBox.js
@@ -191,8 +191,13 @@ const StackRow = ({frame}: StackRowProps) => {
const Text = require('Text');
const TouchableHighlight = require('TouchableHighlight');
const {file, lineNumber} = frame;
const fileParts = file.split('/');
const fileName = fileParts[fileParts.length - 1];
let fileName;
if (file) {
const fileParts = file.split('/');
fileName = fileParts[fileParts.length - 1];
} else {
fileName = '<unknown file>';
}
return (
<TouchableHighlight

0 comments on commit 106ad85

Please sign in to comment.