4

I keep getting EPIPE error, on stdin stream and I can't find a reason:

This is my code:

var checkFile = function(data, callback){
   var child_process = spawn('ffprobe', ['-print_format', 'json', '-show_format', 'pipe:0']);

   var stdInError = function(e) {
       console.log(e);
   }
   child_process.stdin.on('error', stdInError);

   var generalError = function() {
       console.log("general Error" + "\n");
   }
   child_process.on('error', generalError);

   child_process.stdout.on('data', function(data){
        console.log("data" + "\n");
        console.log(data);
        console.log("\n");
   });

   child_process.on('close', function(){
       console.log("close" + "\n");
   }

   var exit = function(){
       console.log("exit");
   }
   child_process.on('exit', exit);

   console.log("write" + "\n");
   child_process.stdin.write(data);
   child_process.stdin.end();
};

And this is my output:

write

data

<Buffer 7b 0a 20 20 20 20 22 66 6f 72 6d 61 74 22 3a 20 7b 0a 20 20 20 20 20 20 20 20 22 66 69 6c 65 6e 61 6d 65 22 3a 20 22 70 69 70 65 3a 30 22 2c 0a 20 20 20 ...>

data

<Buffer 0a 7d 0a>

{ [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }

exit
close

I cannot find a reason for this error, i have also tried to implement

child_process.stderr.on('data', function (data) {
    //throw errors
    console.log('stderr: ' + data);
});

And every line printed from ffprobe (which is a software to check audio/video files specs) is marked as stderr. For example:

stderr: ffprobe version 2.2.4 Copyright (c) 2007-2014 the FFmpeg developers built on Jul 2 2014 15:07:45 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' libavutil 52. 66.100 / 52. 66.100

stderr: libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libavresample 1. 2. 0 / 1. 2. 0 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100

MeV
  • 3,761
  • 11
  • 45
  • 78

1 Answers1

6

After few tests I found a bug and the error is caused by a too big file.

MeV
  • 3,761
  • 11
  • 45
  • 78
  • In my case the file uploaded was too big and reducing the size of it prevented the error – MeV May 12 '16 at 13:36
  • wow I actually can't believe this I had the same issue lmao! thank you! – d0rf47 Dec 16 '20 at 02:15
  • 2
    Excuse me, what has to do file size with this? I'm getting the same erorr but, im just doinf the stdin.write command (with a short string there) – BalB Nov 17 '21 at 08:31
  • I also have this issue. It occurs when the http request body is large. Although, I can't find a solution and reducing the payload is not an option in my case.. – Bence Mar 07 '23 at 12:59