Skip to content

subprocess: list valid signal names in kill() error - #30982

Merged
Jarred-Sumner merged 1 commit into
mainfrom
ali/subprocess-kill-signal-names
May 20, 2026
Merged

Jarred-Sumner merged 1 commit into
mainfrom
ali/subprocess-kill-signal-names

Conversation

@alii

@alii alii commented May 18, 2026

Copy link
Copy Markdown
Member

subprocess.kill("BADSIGNAL") lost its useful error message in the Rust port: it emitted the static placeholder signal must be one of the SignalCode names (naming zero actual signals) instead of the full list released Bun produces.

Build the list from the canonical signal X-macro (matching Zig's comptime toEnumFromMap), so the message is byte-for-byte identical to released Bun again: signal must be one of 'SIGHUP', 'SIGINT', … or 'SIGSYS'. code/name were already correct.

@robobun

robobun commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 7:50 AM PT - May 18th, 2026

✅ @alii, your commit 53af7e836b6f843f8c48b7dcc8574b70ae796bbf passed in Build #55809! 🎉


🧪   To try this PR locally:

bunx bun-pr 30982

That installs a local version of the PR into your bun-30982 executable, so you can run:

bun-30982 --bun

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8ecba821-daf6-4afd-999b-e23ecb6d75ff

📥 Commits

Reviewing files that changed from the base of the PR and between 4c8a21b and 53af7e8.

📒 Files selected for processing (2)
  • src/jsc/lib.rs
  • test/js/bun/spawn/spawn-kill-signal.test.ts

Walkthrough

This PR improves error messages when invalid signal names are passed to subprocess kill operations. The SignalCode conversion now constructs detailed error messages enumerating the valid signal names from bun_core::SIGNAL_NAMES with proper formatting instead of using a generic placeholder, and a test validates this behavior.

Changes

Signal validation error messages with enumerated names

Layer / File(s) Summary
Improve signal validation with enumerated error names
src/jsc/lib.rs, test/js/bun/spawn/spawn-kill-signal.test.ts
The SignalCode conversion fallback now constructs a detailed error message listing allowed signal names from bun_core::SIGNAL_NAMES[1..] with comma and "or" formatting. A new test validates that proc.kill() with an invalid signal name throws TypeError with the expected error code and a message enumerating valid signal names, while confirming proc.kill() with no arguments defaults to SIGTERM.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: improving the error message for subprocess.kill() to list valid signal names instead of a placeholder.
Description check ✅ Passed The description covers the problem (regression in Rust port), the solution (using the canonical signal X-macro), and the expected outcome (byte-for-byte identical to released Bun), but lacks explicit verification details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — restores the enumerated signal-name error message with test coverage.

Extended reasoning...

Overview

This PR touches two files: src/jsc/lib.rs (the FromJsEnum impl for bun_sys::SignalCode) and test/js/bun/spawn/spawn-kill-signal.test.ts. It replaces a terse placeholder error message (signal must be one of the SignalCode names) with the full enumerated list ('SIGHUP', 'SIGINT', … or 'SIGSYS'), restoring byte-for-byte parity with released Bun's Zig toEnumFromMap behavior.

Security risks

None. This is a cold-path error-message formatter that only runs when a user passes an invalid signal string to subprocess.kill(). It reads from a static [&str; 32] constant (bun_core::SIGNAL_NAMES), allocates a small String, and throws. No user-controlled data flows into the message construction beyond triggering the branch.

Level of scrutiny

Low. The change is mechanical string-building over a compile-time-fixed array. I verified SIGNAL_NAMES is [""; SIGHUP..SIGSYS] (32 entries, index 0 sentinel), so [1..] yields exactly 31 names with SIGHUP first and SIGSYS last. The join logic correctly produces ', ' separators with or ' before the final entry, and the array is guaranteed non-empty so the leading ' is always closed.

Other factors

A new regression test asserts the message contains 'SIGHUP', 'SIGTERM', 'SIGKILL', and or 'SIGSYS' while excluding the old placeholder text, and still verifies the process is killable afterward. No bugs were flagged by the bug-hunting system, and there are no outstanding reviewer comments.

@alii

alii commented May 18, 2026

Copy link
Copy Markdown
Member Author

@robobun fix review comments

@robobun

robobun commented May 18, 2026

Copy link
Copy Markdown
Collaborator

@alii I couldn't find any open review comments to address — both reviewers approved with no actionable items:

  • claude[bot]: LGTM
  • coderabbitai[bot]: "No actionable comments were generated in the recent review. 🎉"
  • Review threads: none open

CI is green on Build #55809. If there's specific feedback you'd like addressed, let me know and I'll get on it.

@Jarred-Sumner
Jarred-Sumner merged commit b916187 into main May 20, 2026
6 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the ali/subprocess-kill-signal-names branch May 20, 2026 07:23
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.

3 participants