Skip to content
Myr

Handle exceptions from the `filter` option of `getOneMessage()` (#1091)

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

authored by ehmicky · committed by GitHub · parent e6b012a · Browse files · 4 files+50 added−1 removed
This commit

State

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

Diff stats

4 files+50 added−1 removed

  • tests:+46 added−0 removed
  • other:+4 added−1 removed

4 files+50 added−1 removed

modified:lib/ipc/get-one.js+4 added-1 removed
added:test/fixtures/ipc-get-filter-throw.js+9 added
added:test/fixtures/ipc-send-get.js+8 added
modified:test/ipc/get-one.js+29 added
55 unmodified lines
56 const {ipcOutput} = await subprocess;57 t.deepEqual(ipcOutput, [foobarArray[1]]);58});5960test('Throwing from subprocess.getOneMessage() filter disconnects', async t => {61 const subprocess = execa('ipc-send-get.js', {ipc: true});62 const error = new Error(foobarString);63 t.is(await t.throwsAsync(subprocess.getOneMessage({64 filter() {65 throw error;66 },67 })), error);6869 const {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);70 t.is(exitCode, 1);71 t.false(isTerminated);72 t.true(message.includes('Error: getOneMessage() could not complete'));73 t.deepEqual(ipcOutput, [foobarString]);74});7576test('Throwing from exports.getOneMessage() filter disconnects', async t => {77 const subprocess = execa('ipc-get-filter-throw.js', {ipc: true, ipcInput: 0});78 await t.throwsAsync(subprocess.getOneMessage(), {79 message: /subprocess.getOneMessage\(\) could not complete/,80 });8182 const {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);83 t.is(exitCode, 1);84 t.false(isTerminated);85 t.true(message.includes(`Error: ${foobarString}`));86 t.deepEqual(ipcOutput, []);87});8889test.serial('Can retrieve initial IPC messages under heavy load', async t => {90 await Promise.all(91 Array.from({length: PARALLEL_COUNT}, async (_, index) => {92 const subprocess = execa('ipc-send-argv.js', [`${index}`], {ipc: true, buffer: false});
73 unmodified lines