File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -753,7 +753,7 @@ REPLServer.prototype.createContext = function() {
753
753
} else {
754
754
sendInspectorCommand ( ( session ) => {
755
755
session . post ( 'Runtime.enable' ) ;
756
- session . on ( 'Runtime.executionContextCreated' , ( { params } ) => {
756
+ session . once ( 'Runtime.executionContextCreated' , ( { params } ) => {
757
757
this [ kContextId ] = params . context . id ;
758
758
} ) ;
759
759
context = vm . createContext ( ) ;
@@ -937,7 +937,6 @@ function complete(line, callback) {
937
937
var flat = new ArrayStream ( ) ; // make a new "input" stream
938
938
var magic = new REPLServer ( '' , flat ) ; // make a nested REPL
939
939
replMap . set ( magic , replMap . get ( this ) ) ;
940
- magic . resetContext ( ) ;
941
940
flat . run ( tmp ) ; // eval the flattened code
942
941
// all this is only profitable if the nested REPL
943
942
// does not have a bufferedCommand
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const repl = require ( 'repl' ) ;
5
+ const DEFAULT_MAX_LISTENERS = require ( 'events' ) . defaultMaxListeners ;
6
+
7
+ common . ArrayStream . prototype . write = ( ) => {
8
+ } ;
9
+
10
+ const putIn = new common . ArrayStream ( ) ;
11
+ const testMe = repl . start ( '' , putIn ) ;
12
+
13
+ // https://github.com/nodejs/node/issues/18284
14
+ // Tab-completion should not repeatedly add the
15
+ // `Runtime.executionContextCreated` listener
16
+ process . on ( 'warning' , common . mustNotCall ( ) ) ;
17
+
18
+ putIn . run ( [ '.clear' ] ) ;
19
+ putIn . run ( [ 'async function test() {' ] ) ;
20
+ for ( let i = 0 ; i < DEFAULT_MAX_LISTENERS ; i ++ ) {
21
+ testMe . complete ( 'await Promise.resolve()' , ( ) => { } ) ;
22
+ }
You can’t perform that action at this time.
0 commit comments