From 106ad8592c1f7e88ae42a4045f772aba0db2c7b7 Mon Sep 17 00:00:00 2001 From: Ben Roth Date: Tue, 18 Apr 2017 09:23:29 -0700 Subject: [PATCH] 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 https://github.com/facebook/react-native/pull/13512 Differential Revision: D4896480 Pulled By: javache fbshipit-source-id: 202c793a47abb83a4700a5778a92b0b5828b01a3 --- Libraries/ReactNative/YellowBox.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index ec30f1a84bf..458441f805f 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/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 = ''; + } return (