nodejs/node

process.exit changes of behavior since v20 with an undefined parameter

srapilly opened this issue · 4 comments

Version

v20.1.0

Platform

21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Hi,

Before the v20, process.exit(undefined) had the same behavior than process.exit() without parameter

The listener callback function is invoked with the exit code specified either by the process.exitCode property, or the exitCode argument passed to the process.exit() method.

PR that made the changes: https://github.com/nodejs/node/pull/43716/files#diff-38d3873e06750436cd724af3eb60026b1bb8da914467797cf7ef7a3c94bd74ceL197-L425

is this intended ? This is causing the following issue with npm npm/cli#6399

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

Reproduction file:

process.exitCode = 1

process.exit(undefined)
=> node -v
v20.1.0
=> node ./example.js
=> echo $?
0
=> node -v
v19.9.0
=> node ./example.js
=> echo $?
1

Additional information

No response

Yes, it's intended, and landed as semver-major through a full deprecation cycle. There was a fix for a duplicate issue, but it was not appied as the changed behaviour is correct and more straightforward.

Thanks @daeyeon I didn't saw the existing issue on this, my bad :)

aduh95 commented

Closing as duplicate of #45688