Skip to content

fix: list Node 24 processes in the attach picker on Linux - #2437

Open
om singhal (Om-singhaI) wants to merge 1 commit into
microsoft:mainfrom
Om-singhaI:fix/pick-process-node24-mainthread
Open

om singhal (Om-singhaI) wants to merge 1 commit into
microsoft:mainfrom
Om-singhaI:fix/pick-process-node24-mainthread

Conversation

@Om-singhaI

Copy link
Copy Markdown

Fixes #2385

Node 24 calls uv_thread_setname("MainThread") at startup (src/node.cc on the v24.x branch; v25 uses node-MainThread). On Linux that sets the comm column from ps to MainThread. The picker then shows the process as MainThread and drops it unless it runs with --inspect.

procps also titles both the comm and command columns COMMAND, so indexOf('COMMAND') lands on the comm column. The parser takes the first word of comm as the command, and the PosixProcessTree step that looks for comm in the command line never sees the real one. The posix sample in src/test/node/process-tree.test.ts still passes only because it uses a BINARY header.

This change:

  • finds the command column with lastIndexOf('COMMAND'). macOS heads comm with the aaaa string, so it has one COMMAND.
  • falls back to argv[0] in PosixProcessTree when comm is not in the command line.
  • also uses argv[0] when comm contains a space. That is a title like pm2's node <script>, and searching for it would swallow the whole line and hide the app.

On Linux the command is now the first word of the command line (say /usr/bin/node) and args no longer repeat it, as the posix sample test expects. Matching the node pattern in processPicker.ts instead would keep the MainThread label and change Windows and macOS too.

Tests: six procps style cases in src/ui/processTree/processTree.test.ts (plain node, Node 24 with and without args, Node 25, a pm2 app, a process that set its title). All six fail without the fix and pass with it. npm run test:unit goes from 305 to 311 passing. tsc --noEmit is clean, and so are eslint and dprint check on the touched files. A real macOS ps capture parses identically before and after. The Linux rows follow the procps output format, not a capture from a Linux machine.

Node 24 names its main thread "MainThread", and on Linux ps reports that
name in the comm column, so the process picker filtered the process out.

procps also heads the comm column "COMMAND", so the parser split each line
at comm and never compared it with the command line. Split at the last
"COMMAND" header instead, and fall back to argv[0] when comm does not
appear in the command line.

Also use argv[0] when comm contains whitespace. Such a comm is a process
title, not a binary name: pm2 sets the title to "node <script>", and
searching for it would swallow the whole command line and hide the app.
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.

Attach to process PickProcess do not work with node 24

1 participant