@@ -12,26 +12,34 @@ if (common.isIBMi)
12
12
13
13
common . skipIfInspectorDisabled ( ) ;
14
14
15
+ let gettingDebuggedPid = false ;
16
+
17
+ async function getDebuggedPid ( instance , waitForLog = true ) {
18
+ gettingDebuggedPid = true ;
19
+ const session = await instance . connectInspectorSession ( ) ;
20
+ await session . send ( { method : 'Runtime.enable' } ) ;
21
+ if ( waitForLog ) {
22
+ await session . waitForConsoleOutput ( 'log' , 'safe to debug now' ) ;
23
+ }
24
+ const { value : innerPid } = ( await session . send ( {
25
+ 'method' : 'Runtime.evaluate' , 'params' : { 'expression' : 'process.pid' }
26
+ } ) ) . result ;
27
+ session . disconnect ( ) ;
28
+ gettingDebuggedPid = false ;
29
+ return innerPid ;
30
+ }
31
+
15
32
function restart ( file ) {
16
33
writeFileSync ( file , readFileSync ( file ) ) ;
17
- const interval = setInterval ( ( ) => writeFileSync ( file , readFileSync ( file ) ) , 500 ) ;
34
+ const interval = setInterval ( ( ) => {
35
+ if ( ! gettingDebuggedPid ) {
36
+ writeFileSync ( file , readFileSync ( file ) ) ;
37
+ }
38
+ } , common . platformTimeout ( 500 ) ) ;
18
39
return ( ) => clearInterval ( interval ) ;
19
40
}
20
41
21
42
describe ( 'watch mode - inspect' , ( ) => {
22
- async function getDebuggedPid ( instance , waitForLog = true ) {
23
- const session = await instance . connectInspectorSession ( ) ;
24
- await session . send ( { method : 'Runtime.enable' } ) ;
25
- if ( waitForLog ) {
26
- await session . waitForConsoleOutput ( 'log' , 'safe to debug now' ) ;
27
- }
28
- const { value : innerPid } = ( await session . send ( {
29
- 'method' : 'Runtime.evaluate' , 'params' : { 'expression' : 'process.pid' }
30
- } ) ) . result ;
31
- session . disconnect ( ) ;
32
- return innerPid ;
33
- }
34
-
35
43
it ( 'should start debugger on inner process' , async ( ) => {
36
44
const file = fixtures . path ( 'watch-mode/inspect.js' ) ;
37
45
const instance = new NodeInstance ( [ '--inspect=0' , '--watch' ] , undefined , file ) ;
0 commit comments