-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Nodemon Fails to Wait for Process Exit when using Docker + Inspector #1476
Description
Created per @remy's request in this issue.
It seems that when restarting a process, Nodemon isn't waiting for the old process to completely exit before starting a new one, but:
- only when in a Docker container and
- only when the inspector/debug mode is active.
This issue can be intermittent in applications without a shutdown handler. But, having an application that implements a listener for Nodemon's SIGUSR2 signal that takes even a second or so to complete can be enough to cause this issue to happen reliably.
The presence of --inspect does cause the new process to immediately crash because its trying to open a debug server on the same port that is still in use by the previous process' debug server, but this merely a side-effect of this issue.
If running Nodemon in a Docker container without --inspect, Nodemon correctly waits for the old process to exit, but when --inspect is used inside the container, Nodemon does not wait for the process to exit, leading to an immediate crash.
This can be reproduced with Nodemon 1.18.7 and the following:
$ node -v
v10.13.0
$ docker -v
Docker version 18.09.0, build 4d60db4
$ docker-compose -v
docker-compose version 1.23.1, build b02f1306
Here is a repo that replicates this issue: https://github.com/darkobits/nodemon-restart-issue.