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

nodemon can't kill process under win10 #2141

Closed
TwlightWalker opened this issue Oct 13, 2023 · 5 comments
Closed

nodemon can't kill process under win10 #2141

TwlightWalker opened this issue Oct 13, 2023 · 5 comments
Labels
stale no activity for 2 weeks

Comments

@TwlightWalker
Copy link

TwlightWalker commented Oct 13, 2023

Hello!

The problem - nodemon watch files changing correctly, but can't restart node process under Windows 10.
os: Windows 10 LTSC 17763.615 (10.0.17763.615)
nodemon version: 3.0.1
nodejs version 18.18.0

My way:
There is no error message capturing after executing taskkill at run.js of the nodemon package.
So if there would some errors in shell execution - they will simply disappeared without any tracks and you can't understand what is happened.

In my case node can't find taskkill.exe (may be because of path issues or something alike) but it happening in silence and i could see only result of it - nodemon no restarts node.

So, i change executing taskkill in run.js from

exec( 'taskkill /pid ' + child.pid + ' /T /F' );

to:

exec(
	'%windir%/system32/taskkill.exe /pid ' + child.pid + ' /T /F',
	{ encoding: "binary" },
	e => {
		if ( e ) {
			//this magic converts encoding from cp866 to UTF8, so you can see the problem directly in the console
			const err = "" + e;
			const a = new Uint8Array( err.length );
			for ( let i = 0; i < err.length; i++ ) a[ i ] = err.charCodeAt( i );
			console.error( ( new TextDecoder( "cp866" ) ).decode( a.buffer ) );
		}
	}
);

So the first problem - it is path to the taskkill - i replaced it with real full path to this utility.

%windir% - it is environment variable, which points to WINDOWS directory, and /system32/taskkill.exe - standard path to this utility and its real filename.

And second one - it is errors reporting of the exec command, which ddin't exist.
I fix it and convert output from 866 encoding to UTF8 and print it into console - it helps to understand any problems very much.

I didn't search for other places of exec using in sources, if it uses somewhere else - please add errors reporting to them too.

I wasted about 4 hours to understand all this problems because there was no any errors reporting of them.

Hope, i save some hours to the others.
Anyway, thank you for this tools very much and sorry for my bad english.

@github-actions
Copy link

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@github-actions github-actions bot added the stale no activity for 2 weeks label Oct 27, 2023
@remy remy removed the stale no activity for 2 weeks label Oct 31, 2023
@remy
Copy link
Owner

remy commented Oct 31, 2023

I don't easily have win10 to test with, but I will test this when I have a chance to see if I can replicate, and whether it's worth patching with your suggested change.

@TwlightWalker are you able to replicate with a simple app.js such as (so I can use the same?):

require('http').createServer((req, res) => res.end('ok')).listen(8000);

@TwlightWalker
Copy link
Author

TwlightWalker commented Nov 1, 2023

Thank you for the answer.
Yes, it has been reproduced easily with such app.js.
Anyway it would be good to see exec command stdout, in case of error (callback parameter of the exec command).

Copy link

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@github-actions github-actions bot added the stale no activity for 2 weeks label Nov 15, 2023
Copy link

Automatically closing this issue due to lack of activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity for 2 weeks
Projects
None yet
Development

No branches or pull requests

2 participants