Node process exits with exit code 13 without outputing any error

Author: UlyssesZhCreated May 21, 2025Updated May 21, 2025

I actually suspect this is a Node.js bug, but I am opening an issue here anyway.

javascript
// test.mjs
import { Readable, Writable } from 'stream';
import FfmpegCommand from 'fluent-ffmpeg';

process.on('exit', console.log); // outputs 0, but actual exit code is 13

await new Promise((resolve, reject) => FfmpegCommand()
	.input(Readable.from(Buffer.from(new ArrayBuffer(1000))))
	.inputFormat('f32le')
	.audioChannels(1)
	.audioFrequency(44100)
	.format('wav')
	.pipe(new Writable({ write: chunk => console.log(chunk.length) }))
	.on('end', resolve)
	.on('error', reject)
);

console.log('done'); // never reached
bash
$ node test.mjs && echo good || echo $?
78
0
13

The Node process exits after incomplete ffmpeg output with exit code 13 without outputing any error.

Node version 20.19.0. FFmpeg version 7.1.1.

Source: fluent-ffmpeg/node-fluent-ffmpeg