@@ -748,8 +748,8 @@ function createRepl(inspector) {
748
748
. filter ( ( { location } ) => ! ! location . scriptUrl )
749
749
. map ( ( { location } ) =>
750
750
setBreakpoint ( location . scriptUrl , location . lineNumber + 1 ) ) ;
751
- if ( ! newBreakpoints . length ) return ;
752
- Promise . all ( newBreakpoints ) . then ( ( results ) => {
751
+ if ( ! newBreakpoints . length ) return Promise . resolve ( ) ;
752
+ return Promise . all ( newBreakpoints ) . then ( ( results ) => {
753
753
print ( `${ results . length } breakpoints restored.` ) ;
754
754
} ) ;
755
755
}
@@ -770,16 +770,19 @@ function createRepl(inspector) {
770
770
const breakType = reason === 'other' ? 'break' : reason ;
771
771
const script = knownScripts [ scriptId ] ;
772
772
const scriptUrl = script ? getRelativePath ( script . url ) : '[unknown]' ;
773
- print ( `${ breakType } in ${ scriptUrl } :${ lineNumber + 1 } ` ) ;
773
+
774
+ const header = `${ breakType } in ${ scriptUrl } :${ lineNumber + 1 } ` ;
774
775
775
776
inspector . suspendReplWhile ( ( ) =>
776
777
Promise . all ( [ formatWatchers ( true ) , selectedFrame . list ( 2 ) ] )
777
778
. then ( ( [ watcherList , context ] ) => {
778
779
if ( watcherList ) {
779
780
return `${ watcherList } \n${ inspect ( context ) } ` ;
780
781
}
781
- return context ;
782
- } ) . then ( print ) ) ;
782
+ return inspect ( context ) ;
783
+ } ) . then ( ( breakContext ) => {
784
+ print ( `${ header } \n${ breakContext } ` ) ;
785
+ } ) ) ;
783
786
} ) ;
784
787
785
788
function handleResumed ( ) {
@@ -1026,7 +1029,30 @@ function createRepl(inspector) {
1026
1029
aliasProperties ( context , SHORTCUTS ) ;
1027
1030
}
1028
1031
1032
+ function initAfterStart ( ) {
1033
+ const setupTasks = [
1034
+ Runtime . enable ( ) ,
1035
+ Profiler . enable ( ) ,
1036
+ Profiler . setSamplingInterval ( { interval : 100 } ) ,
1037
+ Debugger . enable ( ) ,
1038
+ Debugger . setPauseOnExceptions ( { state : 'none' } ) ,
1039
+ Debugger . setAsyncCallStackDepth ( { maxDepth : 0 } ) ,
1040
+ Debugger . setBlackboxPatterns ( { patterns : [ ] } ) ,
1041
+ Debugger . setPauseOnExceptions ( { state : pauseOnExceptionState } ) ,
1042
+ restoreBreakpoints ( ) ,
1043
+ Runtime . runIfWaitingForDebugger ( ) ,
1044
+ ] ;
1045
+ return Promise . all ( setupTasks ) ;
1046
+ }
1047
+
1029
1048
return function startRepl ( ) {
1049
+ inspector . client . on ( 'close' , ( ) => {
1050
+ resetOnStart ( ) ;
1051
+ } ) ;
1052
+ inspector . client . on ( 'ready' , ( ) => {
1053
+ initAfterStart ( ) ;
1054
+ } ) ;
1055
+
1030
1056
const replOptions = {
1031
1057
prompt : 'debug> ' ,
1032
1058
input : inspector . stdin ,
@@ -1035,6 +1061,7 @@ function createRepl(inspector) {
1035
1061
useGlobal : false ,
1036
1062
ignoreUndefined : true ,
1037
1063
} ;
1064
+
1038
1065
repl = Repl . start ( replOptions ) ; // eslint-disable-line prefer-const
1039
1066
initializeContext ( repl . context ) ;
1040
1067
repl . on ( 'reset' , initializeContext ) ;
@@ -1044,14 +1071,8 @@ function createRepl(inspector) {
1044
1071
repl . rli . emit ( 'SIGINT' ) ;
1045
1072
} ) ;
1046
1073
1047
- inspector . client . on ( 'close' , ( ) => {
1048
- resetOnStart ( ) ;
1049
- } ) ;
1050
-
1051
- inspector . client . on ( 'ready' , ( ) => {
1052
- restoreBreakpoints ( ) ;
1053
- Debugger . setPauseOnExceptions ( { state : pauseOnExceptionState } ) ;
1054
- } ) ;
1074
+ // Init once for the initial connection
1075
+ initAfterStart ( ) ;
1055
1076
1056
1077
return repl ;
1057
1078
} ;
0 commit comments