ArtskydJ / node-sox-stream

:mega: A stream-friendly wrapper around SoX
53 stars 14 forks source link

Segmentation fault in sox results in a zero-byte stream. #18

Open quasarito opened 5 years ago

quasarito commented 5 years ago

Transcoding a .vox file to .wav to be streamed to a browser to be played resulted in no content in the http response.

      var transcode = sox({
        // equivalent to: play -t raw -r 8000 -c 1 -e mu-law -b 8
        input: { type: 'raw', rate: 8000, encoding: 'mu-law', bits: 8, channels: 1 },
        output: { type: 'wav' }
      });
...
      new stream.PassThrough().end(data.Body)
      .on('error', err => reject(err))
      .pipe(transcode)
      .pipe(res);

It was discovered that the sox binary was causing a segmentation fault. However, the code did not trigger an error. Even having a transcode.on('error', handler) did not call the handler.

Although rare, a segmentation fault in sox library should trigger the 'error' event handler in the library.

nodejs: v12.8.0 sox-stream: v2.0.3 docker image: 12.8.0-alpine sox: 14.4.2-r3