Repository navigation
Add util.convertProcessSignalToExitCode and util.setTraceSigInt - #8329
Conversation
There was a problem hiding this comment.
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
convertProcessSignalToExitCodevalidates input withvalidateOneOfagainstObject.keys(signals)and returns128 + signals[name], as Node does.os.tsre-exports the same frozen signals table with a null prototype, soos.constants.signalsbehaves 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
ba5ac8f to
61ca5f2
Compare
There was a problem hiding this comment.
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
convertProcessSignalToExitCodevalidates input withvalidateOneOfagainstObject.keys(signals)and returns128 + signals[name], as Node does.os.tsre-exports the same frozen signals table with a null prototype, soos.constants.signalsbehaves 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)
61ca5f2 to
bbe18e3
Compare
There was a problem hiding this comment.
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.signalsnow has a frozen null-prototype object as its prototype instead ofnull, which code can observe. (src/node/internal/internal_os_constants.ts:10)
View full review
convertProcessSignalToExitCodevalidates withvalidateOneOfagainst the frozen table's keys and returns128 + 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.tsadds no circular import. os.constants.signalsnow haskNullProtoObjectas its prototype instead ofnull(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.
bbe18e3 to
321406f
Compare
There was a problem hiding this comment.
✅ 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
node:utilwas missingconvertProcessSignalToExitCode(), added in Node.js v24.14.0, andsetTraceSigInt(), added in v24.6.0.In this patch:
convertProcessSignalToExitCode()validates the signal name against theos.constants.signalstable 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.node-internal:internal_os_constants, sonode:utilcan use it without depending onnode:os.util.convertProcessSignalToExitCode('SIGTERM')TypeError(missing)143util.convertProcessSignalToExitCode('SIGFOO')TypeError(missing)ERR_INVALID_ARG_VALUEutil.setTraceSigInt(true)TypeError(missing)undefinedTests are ported from Node's
test-util-convert-signal-to-exit-code.mjs, without thechild_processpart.