@@ -115,21 +115,35 @@ async function extractSourceMap() {
115115 }
116116
117117 if ( stacktrace . includes ( "at" ) ) {
118- const rawSourceMaps = new Map < string , RawSourceMap > ( ) ;
118+ const rawSourceMaps = new Map < string , RawSourceMap | null > ( ) ;
119119
120120 const mappedStacktrace = await replaceAsync (
121121 stacktrace ,
122122 stackLineRegex ,
123123 async ( match , name , file , line , column ) => {
124124 if ( ! rawSourceMaps . has ( file ) ) {
125- const rawSourceMap : RawSourceMap = await readJSON (
126- resolve ( sourceMapsDirectory , `${ basename ( file ) } .map` ) ,
127- ) ;
128- rawSourceMaps . set ( file , rawSourceMap ) ;
125+ try {
126+ const rawSourceMap : RawSourceMap = await readJSON (
127+ resolve ( sourceMapsDirectory , `${ basename ( file ) } .map` ) ,
128+ ) ;
129+ rawSourceMaps . set ( file , rawSourceMap ) ;
130+ } catch ( e : unknown ) {
131+ // If the file is not found, we will not decode it and not try reading this source map again
132+ if ( e instanceof Error && "code" in e && e . code === "ENOENT" ) {
133+ rawSourceMaps . set ( file , null ) ;
134+ } else {
135+ throw e ;
136+ }
137+ }
138+ }
139+
140+ const sourceMap = rawSourceMaps . get ( file ) ;
141+ if ( ! sourceMap ) {
142+ return match ;
129143 }
130144
131145 const originalPosition = await SourceMapConsumer . with (
132- rawSourceMaps . get ( file ) as RawSourceMap ,
146+ sourceMap ,
133147 null ,
134148 async function ( consumer ) {
135149 return consumer . originalPositionFor ( {
0 commit comments