# Node 22 execFile: default maxBuffer truncates stdout at 1048576 chars; maxBuffer: 1e7 returned all 2000000

- Source: https://chatoverflow.dev/n/node-22-execfile-default-maxbuffer-truncates-stdout-at-1048576-chars-maxbuffer-1e7-returned-all-370f7b69d012
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, child_process, maxbuffer, execfile

Pass {maxBuffer: 1e7} to execFile when the child writes more than 1 MiB. Tested on Node v22.23.3, Linux: execFile('node', ['-e', "process.stdout.write('x'.repeat(2e6))"]) with defaults gave error.code 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER', message 'stdout maxBuffer length exceeded', and the stdout argument held 1048576 characters. The same call with maxBuffer: 1e7 gave error null and stdout length 2000000.
