Skip to content

fix(ext/node): improve process.title and support --title flag#32201

Open
bartlomieju wants to merge 10 commits intodenoland:mainfrom
bartlomieju:fix/node-compat-next-tick-error-spin
Open

fix(ext/node): improve process.title and support --title flag#32201
bartlomieju wants to merge 10 commits intodenoland:mainfrom
bartlomieju:fix/node-compat-next-tick-error-spin

Conversation

@bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Feb 16, 2026

Summary

  • Default process.title to process.execPath instead of hardcoded "deno", matching Node.js behavior
  • Make process.title setter functional instead of a no-op
  • Parse --title=<value> from NODE_OPTIONS and set process.title during bootstrap
  • Add --title flag handling in node compat test runner

Test plan

  • cargo test --test node_compat sequential -- --filter test-process-title.js
  • cargo test --test node_compat parallel -- --filter test-process-title-cli.js (WIP - needs build verification)

🤖 Generated with Claude Code

Closes #8592
Closes #31368

bartlomieju and others added 5 commits February 16, 2026 20:35
…ility

Change process.title from hardcoded "deno" to defaulting to
process.execPath, matching Node.js behavior. Also make the setter
functional instead of a no-op. Enable sequential/test-process-title.js
node compat test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse --title=<value> from NODE_OPTIONS and set process.title during
bootstrap. Also add --title flag handling in the node compat test
runner. Enable test-process-title-cli.js node compat test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously process.title only stored the value in a JS variable without
making OS-level changes. Node.js (via libuv) overwrites argv[0] so that
`ps` shows the new title. This adds op_node_process_set_title with
platform-specific implementations:

- macOS: uses _NSGetArgv()/_NSGetArgc() to overwrite argv[0] buffer,
  plus pthread_setname_np for Activity Monitor visibility
- Linux: uses .init_array constructor to capture argv at startup,
  overwrites argv[0] buffer, plus prctl(PR_SET_NAME) for /proc/self/comm
- Windows: uses SetConsoleTitleW

Enables the node_compat test-setproctitle.js test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add explicit unsafe blocks in argv_store for Rust 2024 edition
- Use primordials (StringPrototypeStartsWith/Slice) in node_options.ts
- Update process.title unit test to match new execPath default behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bartlomieju and others added 4 commits March 12, 2026 11:22
CI uses a newer Rust toolchain that requires `#[unsafe(link_section)]`
instead of bare `#[link_section]`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

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

not comfortable approving this as-is

main issue: the NODE_OPTIONS parsing for --title= is too naive.

right now it does:

const args = nodeOptions
  ? StringPrototypeSplit(nodeOptions, new SafeRegExp("\\s"))
  : [];

then checks startsWith("--title=").

that means quoted values with spaces won't parse correctly, even though NODE_OPTIONS='--title=hello world' / NODE_OPTIONS='--title="hello world"' style inputs are exactly where this option becomes useful. you'll either truncate at the first space or include broken quoting.

node's NODE_OPTIONS parsing is shell-like, not plain whitespace splitting, so this is going to diverge in a pretty user-visible way.

also, the linux/mac argv overwrite logic assumes the argv/env memory is one contiguous writable buffer ending at argv[argc-1]. that's the classic trick, but it's pretty invasive and deserves stronger justification/tests before we take it. especially since the PR summary is partly about process.title semantics, but this code is also changing OS-visible process naming behavior.

…ustification

Address review feedback: replace naive whitespace splitting of NODE_OPTIONS
with a shell-like tokenizer that handles single/double quoted values
(e.g. --title="hello world"). Add comments explaining the argv buffer
overwrite technique with references to libuv/Node.js. Add spec tests
for process.title including quoted NODE_OPTIONS values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

npm:clipboardy's clipboard.read() with deno always changes console title to "Windows PowerShell" and dont restore Allow to set process title

2 participants