benjie/mehserve

mehserve crashes when one of the dev services goes down

jeffreywescott opened this issue · 3 comments

It seems like it should just gracefully handle this and retry the connection every few seconds.

mehserve v1.1.1 listening on port 12439
/Users/jeffrey/.nvm/versions/node/v5.5.0/lib/node_modules/mehserve/node_modules/http-proxy/lib/http-proxy/index.js:119
    throw err;
    ^

Error: connect ECONNREFUSED 127.0.0.1:9001
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)

@jeffreywescott Thanks for the bug report! Weird, mehserve handles our dev services up and down tens to hundreds of times per day with no issue...

Looking at the source for http-proxy I can see that they throw error if the proxy doesn't have an error handler (ours doesn't) - however the error you've got should have been caught as part of the request that's being proxied rather than being emitted as a global error on http-proxy. (As a global error we don't have a reference to the request/response and thus can't respond to the initial request with one of our lovely error pages from #1.)

Is this easy to reproduce for you? Does it happen every time?

I've put a trivial error handler into #6 and published a release candidate; try npm install mehserve@1.1.2-rc1 -g and let me know if that solves things for you.

Do you have a non-standard firewall configuration?

Hey, @benjie ... thanks for the super-quick response!

I'll give your rc1 a try.

To answer your questions, nothing weird on my end. One thing I realized though (after I filed the issue) is that it only crashes for me if the service in question is running socketcluster-server and a socketcluster-client connection is connected to it (with auto-reconnect set to true). Not sure if that changes your thoughts at all. In any case, I'll follow-up after I give rc1 a try.

Quick follow-up. rc1 does fix the issue. It still prints the stack trace, but mehserve keeps-on humming.

Thanks a bunch, @benjie.