ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

commit 651854f15567d4328d688a7f032881c3a6ce4c20
parent c7eb6e8be971ae8466cf1b12dddc9cb0373638e4
Author: Dave Hendler <sollaires@gmail.com>
Date:   Wed, 27 May 2015 10:39:02 -0700

Fixes race condition

I ran into a race condition when trimming down the provided application.  If the frontend
bundle finished far enough ahead of the server, the server would fail to start (as that
bundle had not finished processing).

This PR waits for all configs to be bundled before moving onto the next step and solves
this race condition.

Minimal application that triggered the error is in my fork of the repo:
https://github.com/seriallos/react-starter-kit-minimal

Diffstat:
Mgulpfile.js | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gulpfile.js b/gulpfile.js @@ -56,12 +56,15 @@ gulp.task('bundle', function(cb) { var config = require('./webpack.config.js'); var bundler = webpack(config); var verbose = !!argv.verbose; + var numBundled = 0; function bundle(err, stats) { if (err) { throw new $.util.PluginError('webpack', err); } + numBundled++; + console.log(stats.toString({ colors: $.util.colors.supportsColor, hash: verbose, @@ -73,7 +76,7 @@ gulp.task('bundle', function(cb) { cachedAssets: verbose })); - if (!started) { + if (!started && numBundled >= config.length) { started = true; return cb(); }