Repository navigation
fix: list Node 24 processes in the attach picker on Linux - #2437
Open
om singhal (Om-singhaI) wants to merge 1 commit into
Open
om singhal (Om-singhaI) wants to merge 1 commit into
om singhal (Om-singhaI) wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2385
Node 24 calls
uv_thread_setname("MainThread")at startup (src/node.ccon the v24.x branch; v25 usesnode-MainThread). On Linux that sets thecommcolumn frompstoMainThread. The picker then shows the process asMainThreadand drops it unless it runs with--inspect.procps also titles both the
commandcommandcolumnsCOMMAND, soindexOf('COMMAND')lands on the comm column. The parser takes the first word of comm as the command, and thePosixProcessTreestep that looks for comm in the command line never sees the real one. The posix sample insrc/test/node/process-tree.test.tsstill passes only because it uses aBINARYheader.This change:
lastIndexOf('COMMAND'). macOS heads comm with theaaaastring, so it has oneCOMMAND.argv[0]inPosixProcessTreewhen comm is not in the command line.argv[0]when comm contains a space. That is a title like pm2'snode <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 inprocessPicker.tsinstead would keep theMainThreadlabel 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:unitgoes from 305 to 311 passing.tsc --noEmitis clean, and so are eslint anddprint checkon the touched files. A real macOSpscapture parses identically before and after. The Linux rows follow the procps output format, not a capture from a Linux machine.