remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development

Home Page:http://nodemon.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nodemon can't kill process under win10

TwlightWalker opened this issue · comments

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.

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

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);

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).

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

Automatically closing this issue due to lack of activity