From 82dc694c7040b798f000fe451c27a178606feb62 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Fri, 10 Apr 2020 14:13:04 -0700 Subject: [PATCH] Disable the proxy when Mirage is enabled This is to prevent max socket connection errors that can stop the live reload server from responding. --- ui/server/proxies/api.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ui/server/proxies/api.js b/ui/server/proxies/api.js index 9594ffc6c..5678210d6 100644 --- a/ui/server/proxies/api.js +++ b/ui/server/proxies/api.js @@ -7,6 +7,20 @@ module.exports = function(app, options) { // For options, see: // https://github.com/nodejitsu/node-http-proxy + // This is probably not safe to do, but it works for now. + let cacheKey = `${options.project.configPath()}|${options.environment}`; + let config = options.project.configCache.get(cacheKey); + + // Disable the proxy completely when Mirage is enabled. No requests to the API + // will be being made, and having the proxy attempt to connect to Nomad when it + // is not running can result in socket max connections that block the livereload + // server from reloading. + if (config['ember-cli-mirage'].enabled !== false) { + options.ui.writeInfoLine('Mirage is enabled. Not starting proxy'); + delete options.proxy; + return; + } + let proxyAddress = options.proxy; let server = options.httpServer;