Skip to content

Visible shell windows are now popping up on Windows 10 #324

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

Open
lukehaas opened this issue Dec 6, 2021 · 9 comments
Open

Visible shell windows are now popping up on Windows 10 #324

lukehaas opened this issue Dec 6, 2021 · 9 comments

Comments

@lukehaas
Copy link
Contributor

lukehaas commented Dec 6, 2021

Since version 0.8.0 was released, when running this on Windows 10, I'm seeing visible shell windows appear briefly on initialization.

I'm seeing this when running from the main thread of an Electron app.

@rchl
Copy link
Member

rchl commented Dec 6, 2021

Need more information since I don't know how to reproduce that locally.

For a start, can you provide the logs (stderr) that the server produces on start?

@predragnikolic
Copy link
Contributor

FWIW, other have reported similar behavior for other language servers.
See sublimelsp/LSP-volar#38 (comment)

Of note, during initialization, a blank cmd.exe window running node.exe pops up for a split second before it's gone. This doesn't happen with the other Node-based language servers I use.

@rchl
Copy link
Member

rchl commented Dec 6, 2021

You could try enabling disableAutomaticTypingAcquisition (see https://github.com/typescript-language-server/typescript-language-server#initializationoptions). If the problem goes away then we would know which process triggers the console exactly.

The only related thing that has changed (I believe) is that we never use the spawn method for creating the typescript process but always fork the parent process (see more info about differences in https://www.geeksforgeeks.org/difference-between-spawn-and-fork-methods-in-node-js/).

If that causes the console to pop up then I'm not sure if there is any way for me to control that.

Also you should provide the command line arguments that you use to start the server. That would make it clear whether your code was using fork method before.

@lukehaas
Copy link
Contributor Author

lukehaas commented Dec 9, 2021

Thanks, I can confirm that enabling disableAutomaticTypingAcquisition does solve this.

@rchl
Copy link
Member

rchl commented Dec 9, 2021

For reference this is the place where Typescript starts that process: https://github.com/microsoft/TypeScript/blob/e2c89af335e98003fa3a1cf8ec2acbd41add8a68/src/tsserver/nodeServer.ts#L510-L510

child_process.fork has a windowsHide option to prevent the console from popping up on Windows so TypesScript could use that. Though I don't really understand why forking a process there shows the console window while this doesn't happen when this server launched the tsserver process. It also doesn't use windowsHide:

const options = {
silent: true,
execArgv: [
...maxTsServerMemory ? [`--max-old-space-size=${maxTsServerMemory}`] : []
]
};
this.tsserverProc = cp.fork(tsserverPath, args, options);

@lukehaas
Copy link
Contributor Author

lukehaas commented Dec 9, 2021

@rchl from the docs it looks like fork doesn't have the windowsHide option, spawn does though.

@rchl
Copy link
Member

rchl commented Dec 9, 2021

Right, missed that.

BTW. What is the full command that you are running to that this server?

@lukehaas
Copy link
Contributor Author

lukehaas commented Dec 9, 2021

Initially:
node /node_modules/typescript-language-server/lib/cli.js --stdio

Then from the logs I see the command for tsserver is:
node /node_modules/typescript/lib/tsserver.js --logFile ts-logs.txt --logVerbosity verbose --cancellationPipeName /private/var/folders/_4/7kl16n5n3sxfwtjpyzsslsdr0000gn/T/a557efdc706754ca0d9ed63a01ed498c/tscancellation*

@rchl
Copy link
Member

rchl commented Dec 10, 2021

I don't really know why does this happen for you.

Even though I've provided a workaround, I think we could still try to figure out what and why exactly happens here but I'd need to defer that to you or someone else since I don't have a way to look into it.

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

No branches or pull requests

3 participants