bun icon indicating copy to clipboard operation
bun copied to clipboard

NodeJS spawnSync crashes when stdout is set to process.stderr

Open Ponjimon opened this issue 4 months ago • 0 comments

What version of Bun is running?

1.2.15+df017990a

What platform is your computer?

Linux 6.14.8-orbstack-00288-g80b66077b748-dirty aarch64 unknown

What steps can reproduce the bug?

Run this program:

import { spawnSync } from 'child_process';

const proc = spawnSync('pwd', [], {
  encoding: 'utf-8',
  stdio: ['ignore', process.stderr, 'inherit'],
});

What is the expected behavior?

It does not crash with a RangeError

What do you see instead?

1 | import { spawnSync } from 'child_process';
2 | 
3 | const proc = spawnSync('pwd', [], {
                 ^
RangeError: toString() radix argument must be between 2 and 36
      at spawnSync (node:child_process:250:50)
      at /workspaces/xml-to-ses-pipeline/test.ts:3:14
      at loadAndEvaluateModule (2:1)

Bun v1.2.15 (Linux arm64)

Additional information

The above program is a minimal reproduction program. But the same behavior is used by aws-cdk-lib internally and blocks me from using CDK with Bun when it tries to create Lambda functions using the NodejsFunction construct.

https://github.com/aws/aws-cdk/blob/dca8663c63b7b7bb33c205dd7ef6164544978add/packages/aws-cdk-lib/core/lib/private/asset-staging.ts#L205-L212

Ponjimon avatar Jun 11 '25 20:06 Ponjimon