@@ -45,6 +45,7 @@ module.exports = class CiPlugin extends Plugin {
4545 constructor ( ...args ) {
4646 super ( ...args )
4747
48+ this . fileLineToProbeId = new Map ( )
4849 this . rootDir = process . cwd ( ) // fallback in case :session:start events are not emitted
4950
5051 this . addSub ( `ci:${ this . constructor . id } :library-configuration` , ( { onDone } ) => {
@@ -335,7 +336,22 @@ module.exports = class CiPlugin extends Plugin {
335336 } )
336337 }
337338
338- removeDiProbe ( probeId ) {
339+ removeAllDiProbes ( ) {
340+ if ( this . fileLineToProbeId . size === 0 ) {
341+ return Promise . resolve ( )
342+ }
343+ log . debug ( 'Removing all Dynamic Instrumentation probes' )
344+ return Promise . all ( Array . from ( this . fileLineToProbeId . keys ( ) )
345+ . map ( ( fileLine ) => {
346+ const [ file , line ] = fileLine . split ( ':' )
347+ return this . removeDiProbe ( { file, line } )
348+ } ) )
349+ }
350+
351+ removeDiProbe ( { file, line } ) {
352+ const probeId = this . fileLineToProbeId . get ( `${ file } :${ line } ` )
353+ log . warn ( `Removing probe from ${ file } :${ line } , with id: ${ probeId } ` )
354+ this . fileLineToProbeId . delete ( probeId )
339355 return this . di . removeProbe ( probeId )
340356 }
341357
@@ -346,9 +362,27 @@ module.exports = class CiPlugin extends Plugin {
346362 log . warn ( 'Could not add breakpoint for dynamic instrumentation' )
347363 return
348364 }
365+ log . debug ( 'Adding breakpoint for Dynamic Instrumentation' )
366+
367+ this . testErrorStackIndex = stackIndex
368+ const activeProbeKey = `${ file } :${ line } `
369+
370+ if ( this . fileLineToProbeId . has ( activeProbeKey ) ) {
371+ log . warn ( 'Probe already set for this line' )
372+ const oldProbeId = this . fileLineToProbeId . get ( activeProbeKey )
373+ return {
374+ probeId : oldProbeId ,
375+ setProbePromise : Promise . resolve ( ) ,
376+ stackIndex,
377+ file,
378+ line
379+ }
380+ }
349381
350382 const [ probeId , setProbePromise ] = this . di . addLineProbe ( { file, line } , this . onDiBreakpointHit . bind ( this ) )
351383
384+ this . fileLineToProbeId . set ( activeProbeKey , probeId )
385+
352386 return {
353387 probeId,
354388 setProbePromise,
0 commit comments