feat: include "vitest" in the process name#4191
Conversation
|
|
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
|
@AriPerkkio what do you think? |
packages/vitest/src/node/cli.ts
Outdated
| } | ||
|
|
||
| async function start(mode: VitestRunMode, cliFilters: string[], options: CliOptions): Promise<Vitest | undefined> { | ||
| process.title = 'node (vitest)' |
There was a problem hiding this comment.
bun doesn't support changing title yet, but to be future proof we can do process.title += ' (vitest)'
There was a problem hiding this comment.
process.title can not be longer than the original title:
https://nodejs.org/api/process.html#processtitle
on Linux and macOS, process.title is limited to the size of the binary name plus the length of the command-line arguments because setting the process.title overwrites the argv memory of the process
So I assume += will likely crash the runtime on affected platforms.
There was a problem hiding this comment.
I don't see how it will do that from the comment you linked.
There was a problem hiding this comment.
Or are you saying that process.title already fulfills these requirements before reassigning?
There was a problem hiding this comment.
From manual testing it looks like that title cannot be longer than node {filename} - in our case it's probably(?) node vitest.mjs.
When running Vitest, I wasn't able to come up with the name that would not fit in the activity monitor. If you just have a simple file, the limit is reached pretty fast:
process.title = 'node (vitest)'
setTimeout(() => {}, 5000)node t.mjs
Activity monitor shows:
node (vite
There was a problem hiding this comment.
Activity monitor shows:
node (vite
Would vitest (node) be better? 😄
There was a problem hiding this comment.
This problem exists only for this custom file due to the short name. Vitest doesn't have this issue
AriPerkkio
left a comment
There was a problem hiding this comment.
This works for my debugging workflow. 👍
Without the node prefix it would not show in pgrep node so having that is great. We should also add this to entrypoints of node:child_process, e.g. packages/vitest/src/runtime/child.ts
|
Why not just |
Because people look for the "node" process usually. This is why I asked @AriPerkkio opinion here (this change was discussed in a team meeting) |
If your tests spawn external processes you won't see those if you look for process.title = "vitest";
setTimeout(() => {}, 5000);This works: process.title = "node (vitest)";
setTimeout(() => {}, 5000); |
|
I prefer |
|
Also, what if vitest is run in another runtime like |
This should not be a problem because:
|
It will eventually and then you'll have to needlessly change the process name again. I still think |
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.