Skip to content
Myr

Attach error listener to stdio stream (#74)

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

Prevents `Uncaught Exception: write EPIPE` and process crash

authored by Vsevolod Strukchinsky · committed by GitHub · parent 21b418b · Browse files · 4 files+19 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

4 files+19 added−0 removed

  • other:+19 added−0 removed

4 files+19 added−0 removed

added:fixtures/fast-exit-darwinbinary

A binary file, added.

added:fixtures/fast-exit-linuxbinary

A binary file, added.

modified:index.js+7 added
165 unmodified lines
166 spawned.on('error', err => {167 cleanupTimeout();168 resolve({err});169 });170171 if (spawned.stdin) {172 spawned.stdin.on('error', err => {173 cleanupTimeout();174 resolve({err});175 });176 }177 });178179 function destroy() {180 if (spawned.stdout) {
106 unmodified lines
modified:test.js+12 added
355 unmodified lines
356 shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'357 });358 t.is(stdout, 'foo');359});360361if (process.platform !== 'win32') {362 test('write to fast-exit process', async t => {363 // try-catch here is necessary, because this test is not 100% accurate364 // sometimes process can manage to accept input before exiting365 try {366 await m(`fast-exit-${process.platform}`, [], {input: 'data'});367 } catch (err) {368 t.is(err.code, 'EPIPE');369 }370 });371}