File tree 1 file changed +21
-6
lines changed
1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,12 @@ function getModule(filename: string, base?: string): string {
51
51
// To be a part of main module, it has to share the same base
52
52
n = `${ filename } /` . lastIndexOf ( base , 0 ) ;
53
53
if ( n === 0 ) {
54
- let module = filename . substr ( base . length ) . replace ( / \/ / g, '.' ) ;
55
- if ( module ) {
56
- module += ':' ;
54
+ let moduleName = filename . substr ( base . length ) . replace ( / \/ / g, '.' ) ;
55
+ if ( moduleName ) {
56
+ moduleName += ':' ;
57
57
}
58
- module += file ;
59
- return module ;
58
+ moduleName += file ;
59
+ return moduleName ;
60
60
}
61
61
return file ;
62
62
}
@@ -133,8 +133,23 @@ export async function parseStack(stack: stacktrace.StackFrame[]): Promise<StackF
133
133
return parsedFrame ;
134
134
} ) ;
135
135
136
- const sourceFiles = await readSourceFiles ( filesToRead ) ;
136
+ try {
137
+ return addPrePostContext ( filesToRead , frames ) ;
138
+ } catch ( _ ) {
139
+ // This happens in electron for example where we are not able to read files from asar.
140
+ // So it's fine, we recover be just returning all frames without pre/post context.
141
+ return frames ;
142
+ }
143
+ }
137
144
145
+ /**
146
+ * This function tries to read the source files + adding pre and post context (source code)
147
+ * to a frame.
148
+ * @param filesToRead string[] of filepaths
149
+ * @param frames StackFrame[] containg all frames
150
+ */
151
+ async function addPrePostContext ( filesToRead : string [ ] , frames : StackFrame [ ] ) : Promise < StackFrame [ ] > {
152
+ const sourceFiles = await readSourceFiles ( filesToRead ) ;
138
153
return frames . map ( frame => {
139
154
if ( frame . filename && sourceFiles [ frame . filename ] ) {
140
155
try {
You can’t perform that action at this time.
0 commit comments