Write EPIPE error on subsequent Server runs

my error

% bin/middleman server --port 4444      
== The Middleman is loading
== Executing: `WEBPACK_ENV=development ./node_modules/webpack/bin/webpack.js --watch -d --progress --color`
clean-webpack-plugin: /Users/harrymoreno/Code/src/github.com/foo/bar/.tmp has been removed.
  0% compile/Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sources.rb:9:in `read': No such file or directory @ rb_sysopen - /Users/harrymoreno/Code/src/github.com/foo/bar/.tmp/dist/index.bundle.css (Errno::ENOENT)
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sources.rb:9:in `read'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/file_renderer.rb:107:in `template_data_for_file'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/resource.rb:143:in `render'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/rack.rb:112:in `process_request'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/rack.rb:66:in `block in call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/rack.rb:65:in `catch'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/rack.rb:65:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:66:in `block in call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/core_extensions/inline_url_rewriter.rb:61:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/lint.rb:49:in `_call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/lint.rb:37:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/builder.rb:153:in `call'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/mock.rb:74:in `request'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/rack-1.6.4/lib/rack/mock.rb:56:in `get'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/extensions/asset_hash.rb:85:in `manipulate_single_resource'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/extensions/asset_hash.rb:72:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/extensions/asset_hash.rb:72:in `manipulate_resource_list'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/store.rb:234:in `block (4 levels) in ensure_resource_list_updated!'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/util.rb:21:in `instrument'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/store.rb:232:in `block (3 levels) in ensure_resource_list_updated!'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `traverse_depth_first'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:431:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/store.rb:231:in `block (2 levels) in ensure_resource_list_updated!'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/util.rb:21:in `instrument'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/store.rb:224:in `block in ensure_resource_list_updated!'
	from /Users/harrymoreno/.rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/store.rb:221:in `ensure_resource_list_updated!'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/sitemap/extensions/on_disk.rb:21:in `ready'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/callback_manager.rb:57:in `instance_exec'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/callback_manager.rb:57:in `block in execute'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:1316:in `traverse_depth_first'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/hamster-3.0.0/lib/hamster/vector.rb:431:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/callback_manager.rb:57:in `execute'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_reference.rb:43:in `send_to'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/call_with.rb:76:in `call_with'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/contracts-0.13.0/lib/contracts/method_handler.rb:138:in `block in redefine_method'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/callback_manager.rb:28:in `block in install_methods!'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/application.rb:308:in `initialize'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/preview_server.rb:144:in `new'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/preview_server.rb:144:in `initialize_new_app'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-core-4.1.7/lib/middleman-core/preview_server.rb:34:in `start'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-cli-4.1.7/lib/middleman-cli/server.rb:53:in `server'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor.rb:40:in `block in register'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
	from /Users/harrymoreno/.gem/ruby/2.3.0/gems/middleman-cli-4.1.7/bin/middleman:67:in `<top (required)>'
	from bin/middleman:16:in `load'
	from bin/middleman:16:in `<main>'
 40% 1/2 build modules%                                                                                                                                                                   ╭─[~/Code/src/github.com/foo/bar]─[harrymoreno@Harrys-MacBook-Pro]─[1]─[10156]
events.js:141               
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at WriteWrap.afterWrite (net.js:763:14)

My config

configure :development do
  activate :dotenv, env: '.env.development'
  activate :external_pipeline,
           name: :webpack,
           command: "WEBPACK_ENV=development ./node_modules/webpack/bin/webpack.js --watch -d --progress --color",
           source: ".tmp/dist",
           latency: 1
end

If I just run WEBPACK_ENV=development ./node_modules/webpack/bin/webpack.js --watch -d --progress --color that works fine. So I’m assuming there’s an issue with middelmans webServer

In my webpack config I removed clean-webpack-plugin and now the middleman server finds the file /Users/harrymoreno/Code/src/github.com/foo/bar/.tmp/dist/index.bundle.css I suspect this is a race condition between webpacks self cleaning and the middleman server.

How should a middleman app clean generated assets before recompilation and serving?

Previously I had

var Clean = require('clean-webpack-plugin')
...
  plugins: [
    new Clean(['.tmp'])
  ]
}

Is there a way in middleman to delay the server until the external_pipeline is ready? the latency config variable here seems to be the delay between refreshes when a file change is detected, not the sort of delay I need.