-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Server.close does not allow Node process to exit in dev mode #2540
Comments
I believe it's the hot reloading module that's preventing the process to exit. I have noticed the same behavior when implementing a soft kill handler. |
The hot-reloader starting in dev mode seems to start two different webpack middlewares :
But it only stops The module webpack-hot-middleware does not have any I guess the progress on this depends on the progress on the issue of webpack-hot-middleware. |
I found out that the actual problem was coming from I suggest a solution to solve it with this pull request : #3540 |
Expected Behavior
Assuming I've assigned an instance of next to the variable
app
and calledapp.prepare()
, callingapp.close()
should stop all middleware and allow the Node process to exit.Current Behavior
In dev mode, the Node process keeps running with some middleware remaining active. If a page was recently accessed, the "Disposing active pages" message will eventually be logged after
app.close()
was called, indicating that something has not stopped. It will not stop after disposing pages either.When not running in dev mode, the Node process will exit as expected.
Steps to Reproduce (for bugs)
server.js
:Build with
npm run build
Run
node server.js
and point browser at app. The Node process will NOT exit after request is handled. Must Ctrl-C to exit.Run
NODE_ENV=production node server.js
and point browser at app. The Node process will exit after request is handled.Context
Came across this while working on a monitoring app to start/discover/stop instances of a Next app. Instances wouldn't exit when told to via a
/stop
http request.Your Environment
The text was updated successfully, but these errors were encountered: