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 @@ -650,7 +650,7 @@ REPLServer.prototype.createContext = function() {
650
650
} else {
651
651
sendInspectorCommand ( ( session ) => {
652
652
session . post ( 'Runtime.enable' ) ;
653
- session . on ( 'Runtime.executionContextCreated' , ( { params } ) => {
653
+ session . once ( 'Runtime.executionContextCreated' , ( { params } ) => {
654
654
this [ kContextId ] = params . context . id ;
655
655
} ) ;
656
656
context = vm . createContext ( ) ;
@@ -834,7 +834,6 @@ function complete(line, callback) {
834
834
var flat = new ArrayStream ( ) ; // make a new "input" stream
835
835
var magic = new REPLServer ( '' , flat ) ; // make a nested REPL
836
836
replMap . set ( magic , replMap . get ( this ) ) ;
837
- magic . resetContext ( ) ;
838
837
flat . run ( tmp ) ; // eval the flattened code
839
838
// all this is only profitable if the nested REPL
840
839
// 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