Skip to content
Myr

Fix `break` statement with `subprocess.getEachMessage()` (#1082)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 7bf6ac2 · Browse files · 5 files+53 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+53 added−5 removed

  • tests:+42 added−1 removed
  • other:+11 added−4 removed

5 files+53 added−5 removed

modified:lib/io/max-buffer.js-2 removed
modified:lib/ipc/get-each.js+11 added-2 removed
modified:test/fixtures/ipc-echo-twice.js+1 added-1 removed
added:test/fixtures/ipc-iterate-send.js+10 added
modified:test/ipc/get-each.js+31 added
49 unmodified lines
50 const {ipcOutput} = await subprocess;51 t.deepEqual(ipcOutput, foobarArray);52});5354test('break in subprocess.getEachMessage() disconnects', async t => {55 const subprocess = execa('ipc-iterate-send.js', {ipc: true});5657 // eslint-disable-next-line no-unreachable-loop58 for await (const message of subprocess.getEachMessage()) {59 t.is(message, foobarString);60 break;61 }6263 const {ipcOutput} = await subprocess;64 t.deepEqual(ipcOutput, [foobarString]);65});6667const iterateAndError = async (t, subprocess, cause) => {68 // eslint-disable-next-line no-unreachable-loop69 for await (const message of subprocess.getEachMessage()) {70 t.is(message, foobarString);71 throw cause;72 }73};7475test('Exceptions in subprocess.getEachMessage() disconnect', async t => {76 const subprocess = execa('ipc-iterate-send.js', {ipc: true});7778 const cause = new Error(foobarString);79 t.is(await t.throwsAsync(iterateAndError(t, subprocess, cause)), cause);8081 const {ipcOutput} = await subprocess;82 t.deepEqual(ipcOutput, [foobarString]);83});8485const HIGH_CONCURRENCY_COUNT = 10;8687test.serial('Can send many messages at once with exports.getEachMessage()', async t => {88 const subprocess = execa('ipc-iterate.js', {ipc: true});
92 unmodified lines