mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Signed-off-by: Aviv Keller <me@aviv.sh> PR-URL: https://github.com/nodejs/node/pull/64034 Fixes: https://github.com/nodejs/node/issues/64523 Closes: https://github.com/nodejs/node/pull/64534 Fixes: https://github.com/nodejs/node/issues/39387 Closes: https://github.com/nodejs/node/pull/39392 Fixes: https://github.com/nodejs/node/issues/61390 Fixes: https://github.com/nodejs/node/issues/63126 Fixes: https://github.com/nodejs/node/issues/38503 Fixes: https://github.com/nodejs/node/issues/37445 Fixes: https://github.com/nodejs/node/issues/38145 Fixes: https://github.com/nodejs/node/issues/33369 Fixes: https://github.com/nodejs/node/issues/48131 Fixes: https://github.com/nodejs/node/issues/8309 Fixes: https://github.com/nodejs/node/issues/39689 Fixes: https://github.com/nodejs/node/issues/18931 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
// This test verifies that when multiple REPL instances exist concurrently,
|
|
// async errors are correctly routed to the REPL instance that created them.
|
|
|
|
const common = require('../common');
|
|
const { startNewREPLServer } = require('../common/repl');
|
|
const assert = require('assert');
|
|
|
|
// Create two REPLs with separate inputs and outputs
|
|
const {
|
|
replServer: r1,
|
|
input: input1,
|
|
output: output1,
|
|
} = startNewREPLServer({ terminal: false, prompt: 'R1> ' });
|
|
|
|
const {
|
|
replServer: r2,
|
|
input: input2,
|
|
output: output2,
|
|
} = startNewREPLServer({ terminal: false, prompt: 'R2> ' });
|
|
|
|
// Create async error in REPL 1
|
|
input1.emit('data', 'setTimeout(() => { throw new Error("error from repl1") }, 10)\n');
|
|
|
|
// Create async error in REPL 2
|
|
input2.emit('data', 'setTimeout(() => { throw new Error("error from repl2") }, 20)\n');
|
|
|
|
setTimeout(common.mustCall(() => {
|
|
r1.close();
|
|
r2.close();
|
|
|
|
// Verify error from REPL 1 went to REPL 1's output
|
|
assert.match(output1.accumulator, /error from repl1/,
|
|
'REPL 1 should have received its own async error');
|
|
|
|
// Verify error from REPL 2 went to REPL 2's output
|
|
assert.match(output2.accumulator, /error from repl2/,
|
|
'REPL 2 should have received its own async error');
|
|
|
|
// Verify errors did not cross over to wrong REPL
|
|
assert.doesNotMatch(output1.accumulator, /error from repl2/,
|
|
'REPL 1 should not have received REPL 2\'s error');
|
|
assert.doesNotMatch(output2.accumulator, /error from repl1/,
|
|
'REPL 2 should not have received REPL 1\'s error');
|
|
}), 100);
|