@@ -21,6 +21,37 @@ export interface ParsedErrorFrame {
21
21
} ;
22
22
}
23
23
24
+ export type SpecialHermesStackTraceFrameTypes = 'native' | 'address at' | 'empty url' ;
25
+
26
+ function getSpecialHermesStackTraceFrameType ( {
27
+ url,
28
+ } : {
29
+ url : Platform . DevToolsPath . UrlString ,
30
+ } ) : SpecialHermesStackTraceFrameTypes | null {
31
+ // functions implemented in c++.
32
+ // TODO: these might be enhanced to include the C++ loc for the frame
33
+ // so that a debugger could stitch together a hybrid cross-language call stack
34
+ if ( url === 'native' ) {
35
+ return 'native' ;
36
+ }
37
+
38
+ // frames with empty url
39
+ // TODO: these seem to be happening due to a bug that needs to be investigated
40
+ // and produce an actual script URL instead
41
+ if ( url === '' ) {
42
+ return 'empty url' ;
43
+ }
44
+
45
+ // frames pointing to a bytecode locations
46
+ // TODO: these could be symbolicated and link to source files with the help of
47
+ // a bytecode source maps once they are available.
48
+ if ( url . startsWith ?.( 'address at ' ) ) {
49
+ return 'address at' ;
50
+ }
51
+
52
+ return null ;
53
+ }
54
+
24
55
/**
25
56
* Takes a V8 Error#stack string and extracts source position information.
26
57
*
@@ -79,7 +110,8 @@ export function parseSourcePositionsFromErrorStack(
79
110
80
111
const linkCandidate = line . substring ( left , right ) ;
81
112
const splitResult = Common . ParsedURL . ParsedURL . splitLineAndColumn ( linkCandidate ) ;
82
- if ( splitResult . url === '<anonymous>' || splitResult . url === 'native' ) {
113
+ const specialHermesFrameType = getSpecialHermesStackTraceFrameType ( splitResult ) ;
114
+ if ( splitResult . url === '<anonymous>' || specialHermesFrameType !== null ) {
83
115
if ( linkInfos . length && linkInfos [ linkInfos . length - 1 ] . isCallFrame && ! linkInfos [ linkInfos . length - 1 ] . link ) {
84
116
// Combine builtin frames.
85
117
linkInfos [ linkInfos . length - 1 ] . line += `\n${ line } ` ;
0 commit comments