Npm/node still running after server stops

I have phoenix 1.3 configured with npm/webpack. Everything works great, except when I shutdown the dev server, node continues to run. Is this something phoenix is expected to shutdown as well, or do I need to handle that manually?

My endpoint config has this watcher:
watchers: [npm: ["run", "dev", cd: Path.expand("../assets", __DIR__)]]

although I also tried calling node directly, with the same result
watchers: [node: ["node_modules/.bin/webpack-dev-server", "--hot", cd: Path.expand("../assets", __DIR__)]]
which more closely resembles the docs
(the doc seems to imply that phoenix should handle starting & stopping, but maybe I’m mis-reading)

Phoenix handles stopping by closing the stdin pipe to the node process (as is proper unix/posix methods).

A lot of node software is written by people who do not know how to properly close a program when it is told to stop (it should either fork and persist, or it should kill itself when stdin closes), thus it is node being told to close, but whatever node script you are using is not doing things right, in this case it is node_modules/.bin/webpack-dev-server and they should have an issue report.

For note, brunch does things right (they have a stdin switch to do just this). You could potentially wrap the webpage-dev-server call in a script like I detailed elsewhere too (that thread has a lot more information about all this as well, but from a general Port perspective, Ports is how Phoenix handles external programs).


Thanks for the help. I did some digging on webpack-dev-server and found this option that didn’t show up when I ran --help

1 Like

Perfect! Looks like what was needed. :slight_smile:

This is so funny, I just filed an issue with preact-cli for this.

1 Like