Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process title overwrites Windows Command Prompt title #35780

Open
wqoq opened this issue Oct 23, 2020 · 3 comments
Open

process title overwrites Windows Command Prompt title #35780

wqoq opened this issue Oct 23, 2020 · 3 comments

Comments

@wqoq
Copy link

@wqoq wqoq commented Oct 23, 2020

  • Version: v13.3.0
  • Platform: Microsoft Windows 10 Enterprise, 10.0.18363 N/A Build 18363
  • Subsystem: Process

What steps will reproduce the bug?

  1. Open a Windows Command Prompt (using cmd.exe)
  2. Set the title using the title command (e.g. title My Custom App). The title of the window will change to "My Custom App".
  3. Run a node script that sets the process title (e.g. process.title = 'Reticulating splines';)

Step 2 is actually not necessary to exhibit this bug. You can leave the title as the default "Command Prompt", and the same problem still happens. I only mention using a custom title for the reason stated below in "Additional information".

What is the expected behavior?

Under that scenario, following standard Windows Command Prompt behaviour, while the script is running, the window title should change to "My Custom App - Reticulating splines"

What do you see instead?

Under that scenario, while the script is running, the window title instead changes to "Reticulating splines" only.

Additional information

Angular CLI is an example of a very popular package that uses process.title, and I use it daily to run multiple sites at once. I set custom titles for each command window, like "Custom App 1", "Custom App 2", etc..., but when I run them all, all the window titles change to "ng build --watch", which makes it really difficult to tell them apart.

@bzoz
Copy link
Contributor

@bzoz bzoz commented Oct 24, 2020

Sorry, I don't see a bug in Node here. The process.title sets the entire window title, if you want it to add a suffix then you have to do this manually:

const originalTitle= process.title
process.title = `${originalTitle} - Reticulating splines`

if you want your app to restore the title when it exits - then again, you have to do it manually:

process.title = originalTitle

If you are unhappy with how some tools use process.title - which I completely understand and 100% agree with you - then you should bring this up in the issue tracker for that specific tool. Here Node just does whats it is told to do.

@wqoq
Copy link
Author

@wqoq wqoq commented Oct 24, 2020

Yeah, I suspected I would get this response. I had an issue all queued up in Angular CLI's tracker, but had a feeling they would tell me it's Node's problem.

It still feels to me like Node is doing something non-standard if I have to go to every tool that's using Node and tell them they're using it wrong.

Concatenating the titles to get an OS specific behaviour feels more like something Node should be doing, and not the responsibility of all the tools using Node. Ironically, it works perfectly if the tool doesn't even use process.title, so maybe that's what I should be telling them.

@bzoz
Copy link
Contributor

@bzoz bzoz commented Oct 24, 2020

If the tool does not touch process.title then the console title won't change. If the app wants to change the tile, it does this explicitly. Even if Node would only allow adding suffixes to the title, then - besides a lot of people complaining - someone will make a workaround for this using spawn(`title ${newTitle}`) and we are back where we started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.