@@ -154,41 +154,41 @@ function collectStackTrace(
154154 // We mirror how V8 serializes stack frames and how we later parse them.
155155 for ( let i = framesToSkip ; i < structuredStackTrace . length ; i ++ ) {
156156 const callSite = structuredStackTrace [ i ] ;
157- let name = callSite . getFunctionName ( ) || '<anonymous>' ;
157+ let name = typeof callSite . getFunctionName === 'function' ? ( callSite . getFunctionName ( ) || '<anonymous>' ) : ' ';
158158 if (
159159 name . includes ( 'react_stack_bottom_frame' ) ||
160160 name . includes ( 'react-stack-bottom-frame' )
161161 ) {
162162 // Skip everything after the bottom frame since it'll be internals.
163163 break ;
164- } else if ( callSite . isNative ( ) ) {
164+ } else if ( typeof callSite . isNative === 'function' && callSite . isNative ( ) ) {
165165 // $FlowFixMe[prop-missing]
166- const isAsync = callSite . isAsync ( ) ;
166+ const isAsync = typeof callSite . isAsync === 'function' && callSite . isAsync ( ) ;
167167 result . push ( [ name , '' , 0 , 0 , 0 , 0 , isAsync ] ) ;
168168 } else {
169169 // We encode complex function calls as if they're part of the function
170170 // name since we cannot simulate the complex ones and they look the same
171171 // as function names in UIs on the client as well as stacks.
172- if ( callSite . isConstructor ( ) ) {
172+ if ( typeof callSite . isConstructor === 'function' && callSite . isConstructor ( ) ) {
173173 name = 'new ' + name ;
174- } else if ( ! callSite . isToplevel ( ) ) {
174+ } else if ( typeof callSite . isToplevel === 'function' && ! callSite . isToplevel ( ) ) {
175175 name = getMethodCallName ( callSite ) ;
176176 }
177177 if ( name === '<anonymous>' ) {
178178 name = '' ;
179179 }
180- let filename = callSite . getScriptNameOrSourceURL ( ) || '<anonymous>' ;
180+ let filename = typeof callSite . getScriptNameOrSourceURL === 'function' ? ( callSite . getScriptNameOrSourceURL ( ) || '<anonymous>' ) : ' ';
181181 if ( filename === '<anonymous>' ) {
182182 filename = '' ;
183- if ( callSite . isEval ( ) ) {
184- const origin = callSite . getEvalOrigin ( ) ;
183+ if ( typeof callSite . isEval === 'function' && callSite . isEval ( ) ) {
184+ const origin = typeof callSite . getEvalOrigin === 'function' ? callSite . getEvalOrigin ( ) : null ;
185185 if ( origin ) {
186186 filename = origin . toString ( ) + ', <anonymous>' ;
187187 }
188188 }
189189 }
190- const line = callSite . getLineNumber ( ) || 0 ;
191- const col = callSite . getColumnNumber ( ) || 0 ;
190+ const line = ( typeof callSite . getLineNumber === 'function' && callSite . getLineNumber ( ) ) || 0 ;
191+ const col = ( typeof callSite . getColumnNumber === 'function' && callSite . getColumnNumber ( ) ) || 0 ;
192192 const enclosingLine : number =
193193 // $FlowFixMe[prop-missing]
194194 typeof callSite . getEnclosingLineNumber === 'function'
@@ -200,7 +200,7 @@ function collectStackTrace(
200200 ? ( callSite : any ) . getEnclosingColumnNumber ( ) || 0
201201 : 0 ;
202202 // $FlowFixMe[prop-missing]
203- const isAsync = callSite . isAsync ( ) ;
203+ const isAsync = typeof callSite . isAsync === 'function' && callSite . isAsync ( ) ;
204204 result . push ( [
205205 name ,
206206 filename ,
0 commit comments