diff --git a/lib/internal/repl.js b/lib/internal/repl.js index 65c3f77ed6abb9..902e81f495573c 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -107,8 +107,13 @@ function setupHistory(repl, historyPath, ready) { } repl._historyHandle = hnd; repl.on('line', online); - repl.resume(); - return ready(null, repl); + + // reading the file data out erases it + repl.once('flushHistory', function() { + repl.resume(); + ready(null, repl); + }); + flushHistory(); } // ------ history listeners ------ diff --git a/src/node.js b/src/node.js index 2d6ce45a928d29..bd8ef5b04ef8a2 100644 --- a/src/node.js +++ b/src/node.js @@ -130,7 +130,8 @@ // If -i or --interactive were passed, or stdin is a TTY. if (process._forceRepl || NativeModule.require('tty').isatty(0)) { // REPL - Module.requireRepl().createInternalRepl(process.env, function(err, repl) { + var cliRepl = Module.requireRepl(); + cliRepl.createInternalRepl(process.env, function(err, repl) { if (err) { throw err; }