File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 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() {
650650 } else {
651651 sendInspectorCommand ( ( session ) => {
652652 session . post ( 'Runtime.enable' ) ;
653- session . on ( 'Runtime.executionContextCreated' , ( { params } ) => {
653+ session . once ( 'Runtime.executionContextCreated' , ( { params } ) => {
654654 this [ kContextId ] = params . context . id ;
655655 } ) ;
656656 context = vm . createContext ( ) ;
@@ -834,7 +834,6 @@ function complete(line, callback) {
834834 var flat = new ArrayStream ( ) ; // make a new "input" stream
835835 var magic = new REPLServer ( '' , flat ) ; // make a nested REPL
836836 replMap . set ( magic , replMap . get ( this ) ) ;
837- magic . resetContext ( ) ;
838837 flat . run ( tmp ) ; // eval the flattened code
839838 // all this is only profitable if the nested REPL
840839 // 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