nodejs / nodejs/node

unexpected breaking changes with `process.exitCode`/`process.exit()`

Open
#45,683 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed-bug
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

20.0.0-pre (nightly)

Platform

Darwin dib.lan 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64

Subsystem

process

What steps will reproduce the bug?
const assert = require('assert')

process.exitCode = 2
delete process.exitCode // REMOVE
assert(process.exitCode === undefined) // REMOVE
process.exit(undefined)
How often does it reproduce? Is there a required condition?

reproduces on all node versions built after landing #44711

What is the expected behavior?

the assertion should pass, and if the two lines marked REMOVE are commented out the process should exit with code 2

What do you see instead?

the assertion throws, and if the two lines marked REMOVE are commented out the process exits with code 0

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction against a build after #44711 and compare process.exitCode deletion with process.exit(undefined). Done means the assertion passes and the process still exits with code 2 when the marked lines are removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.