@@ -128,6 +128,12 @@ const {
128128} = internalBinding ( 'contextify' ) ;
129129
130130const history = require ( 'internal/repl/history' ) ;
131+ let nextREPLResourceNumber = 1 ;
132+ // This prevents v8 code cache from getting confused and using a different
133+ // cache from a resource of the same name
134+ function getREPLResourceName ( ) {
135+ return `REPL${ nextREPLResourceNumber ++ } ` ;
136+ }
131137
132138// Lazy-loaded.
133139let processTopLevelAwait ;
@@ -578,10 +584,10 @@ function REPLServer(prompt,
578584 if ( e . name === 'SyntaxError' ) {
579585 // Remove stack trace.
580586 e . stack = e . stack
581- . replace ( / ^ r e p l : \d + \r ? \n / , '' )
587+ . replace ( / ^ R E P L \d + : \d + \r ? \n / , '' )
582588 . replace ( / ^ \s + a t \s .* \n ? / gm, '' ) ;
583589 } else if ( self . replMode === module . exports . REPL_MODE_STRICT ) {
584- e . stack = e . stack . replace ( / ( \s + a t \s + r e p l : ) ( \d + ) / ,
590+ e . stack = e . stack . replace ( / ( \s + a t \s + R E P L \d + : ) ( \d + ) / ,
585591 ( _ , pre , line ) => pre + ( line - 1 ) ) ;
586592 }
587593 }
@@ -791,7 +797,7 @@ function REPLServer(prompt,
791797 const evalCmd = self [ kBufferedCommandSymbol ] + cmd + '\n' ;
792798
793799 debug ( 'eval %j' , evalCmd ) ;
794- self . eval ( evalCmd , self . context , 'repl' , finish ) ;
800+ self . eval ( evalCmd , self . context , getREPLResourceName ( ) , finish ) ;
795801
796802 function finish ( e , ret ) {
797803 debug ( 'finish' , e , ret ) ;
@@ -1277,7 +1283,7 @@ function complete(line, callback) {
12771283
12781284 const memberGroups = [ ] ;
12791285 const evalExpr = `try { ${ expr } } catch {}` ;
1280- this . eval ( evalExpr , this . context , 'repl' , ( e , obj ) => {
1286+ this . eval ( evalExpr , this . context , getREPLResourceName ( ) , ( e , obj ) => {
12811287 try {
12821288 let p ;
12831289 if ( ( typeof obj === 'object' && obj !== null ) ||
0 commit comments