fix(ext/node): improve process.title and support --title flag#32201
fix(ext/node): improve process.title and support --title flag#32201bartlomieju wants to merge 10 commits intodenoland:mainfrom
Conversation
…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>
…t-tick-error-spin
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>
kajukitli
left a comment
There was a problem hiding this comment.
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>
Summary
process.titletoprocess.execPathinstead of hardcoded"deno", matching Node.js behaviorprocess.titlesetter functional instead of a no-op--title=<value>fromNODE_OPTIONSand setprocess.titleduring bootstrap--titleflag handling in node compat test runnerTest plan
cargo test --test node_compat sequential -- --filter test-process-title.jscargo test --test node_compat parallel -- --filter test-process-title-cli.js(WIP - needs build verification)🤖 Generated with Claude Code
Closes #8592
Closes #31368