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

Hangs on restarting. #69

Closed
Derya opened this issue May 17, 2019 · 7 comments
Closed

Hangs on restarting. #69

Derya opened this issue May 17, 2019 · 7 comments

Comments

@Derya
Copy link

Derya commented May 17, 2019

There's no lag nor delay nor CPU usage. I just get a message such as:

[INFO] 10:08:17 Restarting: /Users/derya/cvr/cvr-reports/app/routes/main.ts has been modified

And nothing else. It never actually restarts or rebuilds the project. How do I debug this?

@Derya
Copy link
Author

Derya commented May 17, 2019

I tried with the --debug flag:

[INFO] 15:15:29 Restarting: /Users/derya/cvr/cvr-reports/app/routes/main.ts has been modified
[DEBUG] 15:15:29 /Users/derya/cvr/cvr-reports/app/routes/main.ts compiled in 219 ms
[DEBUG] 15:15:29 Removing all watchers from files
[DEBUG] 15:15:29 Child is still running, restart upon exit
[DEBUG] 15:15:29 Disconnecting from child
[DEBUG] 15:15:29 Sending SIGTERM kill to child pid 91901

Looks like maybe the child process won't quit? This is ts-node-dev 1.0.0-pre.38 and typescript 3.4.5

edit: I suppose I should add that I am running ts-node-dev via

ts-node-dev --respawn --debug --ignore-watch node_modules -- ./app/app.ts

@wclr
Copy link
Owner

wclr commented May 18, 2019

See docs:

In some rare cases ts-node-dev may fail to terminate an application by sending SIGTERM signal, this may be caused by the app having running heavy child process or something. But the app should get the signal anyway and it can be explicitly processed there: process.on('SIGTERM', () => process.exit()).

Try maybe it would work for your case.

@Derya
Copy link
Author

Derya commented May 21, 2019

Yep that worked, thanks!

@Derya Derya closed this as completed May 21, 2019
@Derya
Copy link
Author

Derya commented May 21, 2019

Oh maybe I should add though, I don't think that the app is running heavy child processes. It's an express app, so it's listening on some port, but I've had bigger express apps continue to refresh with ts-node-dev just fine. Back when I was debugging this, I tried turning off a few different parts of it, and couldn't figure out what the culprit was between my 1 express app that respected the SIGTERM and my new app that didn't.

@wclr
Copy link
Owner

wclr commented May 22, 2019

I too don't know exactly what may cause it, I actually met with some apps that spawned other processes like (chrome headless, etc). Anyway, I always process SIGTERM in apps because kubernetes cluster sends the signal before it is going to shut down the container, so the app may stop its work gracefully, and in dev mode, I just do process.exit().

@ouraios
Copy link

ouraios commented Feb 11, 2020

The hangs on restarting can also happen because of a bad exception handling : #120

@KresimirCosic
Copy link

KresimirCosic commented Apr 27, 2021

I have gotten this problem when using prisma for database management. It's practically a boilerplate code so it's not heavy per se, but no idea what was causing this issue. The solution above solved it.

Apparently, giving this flag to my npm script also does this magic:

--exit-child - Adds 'SIGTERM' exit handler in a child process.

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

No branches or pull requests

4 participants