webpack-hot-middleware icon indicating copy to clipboard operation
webpack-hot-middleware copied to clipboard

Middleware is preventing process from exiting

Open michalkvasnicak opened this issue 9 years ago • 7 comments

Process which uses this middleware is running until last connection is closed. This is happening even if I call close() on WebpackDevServer.

Something like this could help https://github.com/webpack/webpack-dev-server/blob/v2.1.0-beta.8/lib/Server.js#L386

michalkvasnicak avatar Oct 03 '16 16:10 michalkvasnicak

Ah, good point - calling unref() on the SSE sockets would probably work too.

glenjamin avatar Oct 03 '16 17:10 glenjamin

You mean adding req.socket.unref() somewhere here? https://github.com/glenjamin/webpack-hot-middleware/blob/master/middleware.js#L61

Because it does not help.

michalkvasnicak avatar Oct 03 '16 19:10 michalkvasnicak

Yeah, that's what I meant - it should be enough.

Could you give https://github.com/mafintosh/why-is-node-running a go to see what it thinks is keeping the process up?

glenjamin avatar Oct 03 '16 19:10 glenjamin

I am sorry but why-is-node-running is not working for me. I've noticed that when I sent ctrl + c to process, it hangs only if there is a tab in a browser navigated to this server. So it has to do something with sockets. When I remove this middleware it terminates as expected.

michalkvasnicak avatar Oct 04 '16 09:10 michalkvasnicak

Can you try logging out

process._getActiveHandles()
// and
process._getActiveRequests()

At the point when you think the process should be shutting down cleanly?

glenjamin avatar Oct 05 '16 08:10 glenjamin

Having the same problem you can use: https://github.com/myndzi/wtfnode

I think one culprit is req.socket. The sockets need to be closed to allow the process to exit.

tjmehta avatar Oct 07 '16 23:10 tjmehta

Not 100% sure if you're experiencing the same issue but I did have a similar problem which was caused by a bug in chokidar

richardscarrott avatar Oct 20 '16 19:10 richardscarrott