leeluolee/puer

Can not programatically shut down middleware

HoverBaum opened this issue · 2 comments

For a project I want to use puer as a middleware.

To be able to test my code and expose my project as a module which can be started and stopped I need to stop the http.server that uses puer as an express middleware. However I can not seem to do this.

Here is the most basic setup for this in a repo. Running test.js it should create the server and then close it 5 seconds later. However the process keeps running.

Doing some research on the matter I found that you can actually log active handles in node so I did that with and without the puer middleware and stored the results in this gist. As can be seen here the puer middleware adds a file listener for each file in the watched folder and a timer to the stack. One of these keeps the process from exiting by still running. I am however not sure which one.

It would be awesome if the middleware would shut itself down when the http server closes or at least expose a function to clear all timers and file watcher it created.

Thanks for so detailed description, I will solve it in the weekend

Any progress on this?