Disable the proxy when Mirage is enabled

This is to prevent max socket connection errors that can stop
the live reload server from responding.
This commit is contained in:
Michael Lange 2020-04-10 14:13:04 -07:00
parent 7a4852d44b
commit 82dc694c70
1 changed files with 14 additions and 0 deletions

View File

@ -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;