Skip to content

Add util.convertProcessSignalToExitCode and util.setTraceSigInt - #8329

Merged
littledivy merged 1 commit into
mainfrom
littledivy/2026-11-09-signal-exit-code
Nov 11, 2026
Merged

littledivy merged 1 commit into
mainfrom
littledivy/2026-11-09-signal-exit-code

Conversation

@littledivy

Copy link
Copy Markdown
Member

node:util was missing convertProcessSignalToExitCode(), added in Node.js v24.14.0, and setTraceSigInt(), added in v24.6.0.

In this patch:

  • convertProcessSignalToExitCode() validates the signal name against the os.constants.signals table and returns 128 plus the signal number, as Node does.
  • setTraceSigInt() is a no-op, since Workers never receive SIGINT. Node doesn't validate its argument either.
  • The signals table moves to node-internal:internal_os_constants, so node:util can use it without depending on node:os.
before after
util.convertProcessSignalToExitCode('SIGTERM') TypeError (missing) 143
util.convertProcessSignalToExitCode('SIGFOO') TypeError (missing) throws ERR_INVALID_ARG_VALUE
util.setTraceSigInt(true) TypeError (missing) undefined

Tests are ported from Node's test-util-convert-signal-to-exit-code.mjs, without the child_process part.

@littledivy
littledivy requested review from a team as code owners November 10, 2026 05:40

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 61ca5f2b.

This review, of ba5ac8ff

💬 Approved with comments — The implementation is correct and tested. The only note is an INFO: the commit message should record the compatibility decision for the new public API in node:util.

Findings: 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

Correct implementation; one process note about recording the compatibility decision for the new API.

Recommendation: 💬 Optional Nits

  • [INFO] New public API in node:util; the commit message does not record the compatibility decision (a flag, or an explicit acceptance of the risk) that the repository's backward-compatibility guidance asks for. (src/node/util.ts:449)
View full review
  • convertProcessSignalToExitCode validates input with validateOneOf against Object.keys(signals) and returns 128 + signals[name], as Node does.
  • os.ts re-exports the same frozen signals table with a null prototype, so os.constants.signals behaves as before.
  • The tests cover the named and default exports, valid signals and invalid inputs.

One process note: the repository's guidance asks that new API surface for Workers come with a compatibility decision in the commit message. The commit message does not record one.


✅ All other checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md issues.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: ba5ac8ff

Comment thread src/node/util.ts Resolved
@littledivy
littledivy force-pushed the littledivy/2026-11-09-signal-exit-code branch from ba5ac8f to 61ca5f2 Compare November 10, 2026 14:37

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of bbe18e33.

This review, of 61ca5f2b

💬 Approved with comments — The implementation is correct and tested. The only note is an INFO: the commit message should record the compatibility decision for the new public API in node:util.

Findings: 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

Correct implementation; one process note about recording the compatibility decision for the new API.

Recommendation: 💬 Optional Nits

  • [INFO] New public API in node:util; the commit message does not record the compatibility decision (a flag, or an explicit acceptance of the risk) that the repository's backward-compatibility guidance asks for. (src/node/util.ts:449)
View full review
  • convertProcessSignalToExitCode validates input with validateOneOf against Object.keys(signals) and returns 128 + signals[name], as Node does.
  • os.ts re-exports the same frozen signals table with a null prototype, so os.constants.signals behaves as before.
  • The tests cover the named and default exports, valid signals and invalid inputs.

One process note: the repository's guidance asks that new API surface for Workers come with a compatibility decision in the commit message. The commit message does not record one.


✅ All other checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md issues.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 61ca5f2b — same changes as ba5ac8ff, so this is that commit's review (no new review was run; line numbers are as of ba5ac8ff)

@littledivy
littledivy force-pushed the littledivy/2026-11-09-signal-exit-code branch from 61ca5f2 to bbe18e3 Compare November 11, 2026 03:23

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 321406f5.

This review, of bbe18e33

💬 Approved with comments — The change is correct and tested. The only note is an INFO: os.constants.signals no longer has a null prototype, and code can observe that.

Findings: 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

Correct and tested. One INFO: the prototype of os.constants.signals has changed in a way code can observe.

Recommendation: 💬 Optional Nits

  • [INFO] os.constants.signals now has a frozen null-prototype object as its prototype instead of null, which code can observe. (src/node/internal/internal_os_constants.ts:10)
View full review
  • convertProcessSignalToExitCode validates with validateOneOf against the frozen table's keys and returns 128 + n. The named and default exports are both wired up, and the tests cover valid signals, invalid values and both export paths.
  • Moving the table out of os.ts adds no circular import.
  • os.constants.signals now has kNullProtoObject as its prototype instead of null (see the inline note).

✅ All other checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md issues.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: bbe18e33

node:util was missing convertProcessSignalToExitCode(), added in
Node.js v24.14.0, and setTraceSigInt(), added in v24.6.0.

In this patch convertProcessSignalToExitCode() validates the signal
name against the os.constants.signals table and returns 128 plus the
signal number, as Node.js does. setTraceSigInt() is a no-op since
Workers never receive SIGINT.

- Move the signals table to node-internal:internal_os_constants so
  node:util can use it without depending on node:os.
- Add kNullProtoObject to internal_utils and use it as the table's
  prototype instead of null, which keeps it out of V8's dictionary
  mode. Object.getPrototypeOf(os.constants.signals) is now that
  frozen object rather than null; os-test pins this.

Both are new exports of node:util, which is only available under
nodejs_compat, so they ship without a compatibility flag: code that
doesn't call them can't observe them, as with earlier node:util
additions.
@littledivy
littledivy force-pushed the littledivy/2026-11-09-signal-exit-code branch from bbe18e3 to 321406f Compare November 11, 2026 03:54

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — The new util APIs are correct and tested, the signals table move is clean, and the only earlier note covers a prototype change the discussion asked for and a new test checks.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md issues.


📋 Code Quality: ✅ LGTM

convertProcessSignalToExitCode validates its argument against the frozen signals table and returns 128 + n. setTraceSigInt is a no-op. Both are wired into the named and default exports, and the tests cover valid signals, invalid values and both export paths. The kNullProtoObject prototype on os.constants.signals is the pattern requested in the discussion, and the new os-test.js checks it.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 321406f5

@littledivy
littledivy merged commit 16784a2 into main Nov 11, 2026
23 of 25 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-09-signal-exit-code branch November 11, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants