Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,11 @@ function REPLServer(prompt,
self.output.write(self.writer(ret) + '\n');
}

// Display prompt again
self.displayPrompt();
// Display prompt again (unless we already did by emitting the 'error'
// event on the domain instance).
if (!e) {
self.displayPrompt();
}
}
});

Expand Down
23 changes: 23 additions & 0 deletions test/parallel/test-repl-uncaught-exception-evalcallback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');
const { PassThrough } = require('stream');
const input = new PassThrough();
const output = new PassThrough();

const r = repl.start({
input, output,
eval: common.mustCall((code, context, filename, cb) => {
r.setPrompt('prompt! ');
cb(new Error('err'));
})
});

input.end('foo\n');

// The output includes exactly one post-error prompt.
const out = output.read().toString();
assert.match(out, /prompt!/);
assert.doesNotMatch(out, /prompt![\S\s]*prompt!/);
output.on('data', common.mustNotCall());