node/test/parallel/test-repl-null-thrown.js
Benjamin Gruenbaum 030a0285d8 repl: don't terminate on null thrown
Previous behavior was to assume an error is a proper error in the
repl module. A check was added to not terminate the process on thrown
repl errors that are `null` or `undefined`.

PR-URL: https://github.com/nodejs/node/pull/14306
Fixes: https://github.com/nodejs/node/issues/12373
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
2017-07-19 12:20:09 +03:00

25 lines
540 B
JavaScript

'use strict';
require('../common');
const repl = require('repl');
const assert = require('assert');
const Stream = require('stream');
const output = new Stream();
let text = '';
output.write = output.pause = output.resume = function(buf) {
text += buf.toString();
};
const replserver = repl.start({
output: output,
input: process.stdin
});
replserver.emit('line', 'process.nextTick(() => { throw null; })');
replserver.emit('line', '.exit');
setTimeout(() => {
console.log(text);
assert(text.includes('Thrown: null'));
}, 0);