When a connection to the agent fails with ECONNREFUSED, the restify domain's handler catches the error and we end up not calling /wait from the client. This means that:
docker run --rm node
sometimes works and sometimes bails because the container is still running (when we haven't run wait to see it stop). This fix makes it so that when a connection is refused we get the normal 400 response instead and the client calls wait.
When a connection to the agent fails with ECONNREFUSED, the restify domain's handler catches the error and we end up not calling /wait from the client. This means that:
sometimes works and sometimes bails because the container is still running (when we haven't run wait to see it stop). This fix makes it so that when a connection is refused we get the normal 400 response instead and the client calls wait.