@@ -10,6 +10,11 @@ const LRU_FILE_CONTENTS_CACHE = new LRUMap<string, Record<number, string>>(10);
10
10
const LRU_FILE_CONTENTS_FS_READ_FAILED = new LRUMap < string , 1 > ( 20 ) ;
11
11
const DEFAULT_LINES_OF_CONTEXT = 7 ;
12
12
const INTEGRATION_NAME = 'ContextLines' ;
13
+ // Determines the upper bound of lineno/colno that we will attempt to read. Large colno values are likely to be
14
+ // minified code while large colno values are likely to be bundled code.
15
+ // Exported for testing purposes.
16
+ export const MAX_CONTEXTLINES_COLNO : number = 1000 ;
17
+ export const MAX_CONTEXTLINES_LINENO : number = 10000 ;
13
18
14
19
interface ContextLinesOptions {
15
20
/**
@@ -58,6 +63,15 @@ function shouldSkipContextLinesForFile(path: string): boolean {
58
63
if ( path . startsWith ( 'data:' ) ) return true ;
59
64
return false ;
60
65
}
66
+
67
+ /**
68
+ * Determines if we should skip contextlines based off the max lineno and colno values.
69
+ */
70
+ function shouldSkipContextLinesForFrame ( frame : StackFrame ) : boolean {
71
+ if ( frame . lineno !== undefined && frame . lineno > MAX_CONTEXTLINES_LINENO ) return true ;
72
+ if ( frame . colno !== undefined && frame . colno > MAX_CONTEXTLINES_COLNO ) return true ;
73
+ return false ;
74
+ }
61
75
/**
62
76
* Checks if we have all the contents that we need in the cache.
63
77
*/
@@ -216,7 +230,8 @@ async function addSourceContext(event: Event, contextLines: number): Promise<Eve
216
230
! frame ||
217
231
typeof filename !== 'string' ||
218
232
typeof frame . lineno !== 'number' ||
219
- shouldSkipContextLinesForFile ( filename )
233
+ shouldSkipContextLinesForFile ( filename ) ||
234
+ shouldSkipContextLinesForFrame ( frame )
220
235
) {
221
236
continue ;
222
237
}
0 commit comments