You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The point of the comparison is to show that it is possible to run cmd and bat files without requiring a console window open the whole time. It would just be a matter of figuring out how .net is doing it and plugging into that same mechanism when running on Windows vs however nodejs is currently doing things.
But I really think this issue is long overdue to be addressed.
Nice, that probably bodes well for a fix then because it means that nodejs isn't doing anything wrong in how it spawns, it's just not fully abstracted over this Windows-specific nuance?
Cool, is this something that can be exposed as another option to spawn and exec? Without claiming to be a whiz with C++ or nodejs internals, conceptually this sounds pretty low risk. And I mean, this is an issue that's been spoken about since at least 2015 -- pretty low hanging fruit for such a high impact.
@atrauzzi I've opened #15380, which exposes UV_PROCESS_WINDOWS_HIDE as windowsHide in the child_process methods. I don't have a Windows box on hand to test with at the moment, so could you or another Windows user see if that fixes the problem.
I've tested #15380 but it looks like it does not solve the issue. But I'm also not confident that I've tested the right thing.
@atrauzzi could you provide a small example of how to reproduce the console popping? It would be great if it would be in pure Node.js, but since this looks related to the PM2 internals, an example that uses PM2 will work for now.
@atrauzzi the example looks like workaround the issue using edge-js. Could you provide some code that demonstrates the console window popping in and out?
I can't remember off the top of my head at the moment what the correct combination is. But I believe there's a combination that results in a window popping open when it really shouldn't be.
Well, an exact combination would be very helpful 😉. I'm not even sure what am I looking for, the more detailed instructions you provide the easier it will be for me to find the issue and fix it.
After libuv PR it still looks like it does not work as intended.
I've included libuv/libuv#1558 and #15380 in my Node build. I've included windowsHide: true in the spawn call (ForkMode.js:94). Since MSDN says using detached: true disables flag from libuv/libuv#1558, I've tied this two times with and without detached: true (with pm2 update in the middle).
I've created an empty file test.js. And I called: node bin/pm2 start test.js. Once in a while a console window would pop in for a split-second.
Sorry, been very busy lately, but I just wanted to catch up -- Will the fix(es?) planned allow me to spawn a process with a shell, but without a window accompanying it? My main case here is that I need to have access to the default shell environment of the current user when spawning.
Activity
mscdex commentedon Sep 6, 2017
I think this snippet from the C# code you referenced pretty much says it all:
A console window is still being created. So C# is really doing the same thing, except it is removing the window from the taskbar.
atrauzzi commentedon Sep 6, 2017
Nice, that probably bodes well for a fix then because it means that nodejs isn't doing anything wrong in how it spawns, it's just not fully abstracted over this Windows-specific nuance?
bnoordhuis commentedon Sep 6, 2017
Libuv supports it (the
UV_PROCESS_WINDOWS_HIDEflag touv_spawn()) but node.js hasn't exposed it so far.atrauzzi commentedon Sep 6, 2017
Cool, is this something that can be exposed as another option to
spawnandexec? Without claiming to be a whiz with C++ or nodejs internals, conceptually this sounds pretty low risk. And I mean, this is an issue that's been spoken about since at least 2015 -- pretty low hanging fruit for such a high impact.cjihrig commentedon Sep 10, 2017
@atrauzzi if you follow the logic of
windowsVerbatimArguments, you should be able to implement something similar for this flag.atrauzzi commentedon Sep 11, 2017
I suspect it would make more sense for someone familiar with C++ dev to implement this.
cjihrig commentedon Sep 13, 2017
@atrauzzi I've opened #15380, which exposes
UV_PROCESS_WINDOWS_HIDEaswindowsHidein thechild_processmethods. I don't have a Windows box on hand to test with at the moment, so could you or another Windows user see if that fixes the problem.bzoz commentedon Sep 14, 2017
I've tested #15380 but it looks like it does not solve the issue. But I'm also not confident that I've tested the right thing.
@atrauzzi could you provide a small example of how to reproduce the console popping? It would be great if it would be in pure Node.js, but since this looks related to the PM2 internals, an example that uses PM2 will work for now.
bnoordhuis commentedon Sep 21, 2017
Ping @atrauzzi.
atrauzzi commentedon Sep 21, 2017
I put together a quick example as part of this ticket's initial description if that's enough?
bzoz commentedon Sep 21, 2017
You mean this: https://gist.github.com/atrauzzi/bbcc171b57a7ea276a2e6bf6419c7e51 ?
atrauzzi commentedon Sep 21, 2017
Yeah.
refack commentedon Sep 21, 2017
How serendipitous 😄 this is what's been stopping me from using this in #14042
bzoz commentedon Sep 22, 2017
@atrauzzi the example looks like workaround the issue using edge-js. Could you provide some code that demonstrates the console window popping in and out?
atrauzzi commentedon Sep 22, 2017
You can play with this module and flip the flags around in the node-native spawn:
https://github.com/atrauzzi/gerty/blob/master/src/Spawn.ts#L15-L35
I can't remember off the top of my head at the moment what the correct combination is. But I believe there's a combination that results in a window popping open when it really shouldn't be.
bzoz commentedon Sep 22, 2017
Well, an exact combination would be very helpful 😉. I'm not even sure what am I looking for, the more detailed instructions you provide the easier it will be for me to find the issue and fix it.
bzoz commentedon Sep 25, 2017
After libuv PR it still looks like it does not work as intended.
I've included libuv/libuv#1558 and #15380 in my Node build. I've included
windowsHide: truein thespawncall (ForkMode.js:94). Since MSDN says usingdetached: truedisables flag from libuv/libuv#1558, I've tied this two times with and withoutdetached: true(withpm2 updatein the middle).I've created an empty file
test.js. And I called:node bin/pm2 start test.js. Once in a while a console window would pop in for a split-second.child_process: add windowsHide option
child_process: add windowsHide option
child_process: add windowsHide option
child_process: add windowsHide option
atrauzzi commentedon Nov 6, 2017
Sorry, been very busy lately, but I just wanted to catch up -- Will the fix(es?) planned allow me to spawn a process with a shell, but without a window accompanying it? My main case here is that I need to have access to the default shell environment of the current user when spawning.
toddwong commentedon Nov 28, 2017
Will cluster.fork honor this windowsHide eventually? It calls child_process.fork without this option for now I think.