Skip to content
Myr

Better error message on IPC `EPIPE` (#1088)

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

authored by ehmicky · committed by GitHub · parent e8bab97 · Browse files · 3 files+35 added−0 removed
This commit

State

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

Diff stats

3 files+35 added−0 removed

  • tests:+26 added−0 removed
  • other:+9 added−0 removed

3 files+35 added−0 removed

modified:lib/ipc/send.js+2 added
modified:lib/ipc/validation.js+7 added
modified:test/ipc/send.js+26 added
79 unmodified lines
80 t.is(exitCode, 1);81 t.false(isTerminated);82 t.true(stderr.includes('sendMessage()\'s argument type is invalid'));83});8485// EPIPE happens based on timing conditions, so we must repeat it until it happens86const findEpipeError = async t => {87 // eslint-disable-next-line no-constant-condition88 while (true) {89 // eslint-disable-next-line no-await-in-loop90 const error = await t.throwsAsync(getEpipeError());91 if (error.cause?.code === 'EPIPE') {92 return error;93 }94 }95};9697const getEpipeError = async () => {98 const subprocess = execa('empty.js', {ipc: true});99 // eslint-disable-next-line no-constant-condition100 while (true) {101 // eslint-disable-next-line no-await-in-loop102 await subprocess.sendMessage('.');103 }104};105106test.serial('Can send messages while the subprocess is closing', async t => {107 const {message} = await findEpipeError(t);108 t.is(message, 'subprocess.sendMessage() cannot be used: the subprocess is disconnecting.');109});