-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
Sometimes the preprocessors and compilers call their callback synchronously. In those cases, async.eachSeries will recurse synchronously, and the call stack will grow very large. Also see caolan/async#75 (comment) and caolan/async#173 (comment). Incidentally, this cuts initial build time in half.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,11 +110,13 @@ Generator.prototype.preprocess = function (callback) { | |
async.eachSeries(paths, function (path, pathCallback) { | ||
if (path.slice(-1) === '/') { | ||
mkdirp.sync(self.preprocessDest + '/' + path) | ||
pathCallback() | ||
process.nextTick(pathCallback) // async to avoid long stack traces | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joliss
Author
Member
|
||
} else { | ||
var possiblePreprocessors = [].concat(package.preprocessors, self.preprocessors) | ||
processFile(package.srcDir, path, possiblePreprocessors, function (err) { | ||
pathCallback(err) | ||
process.nextTick(function () { // async to avoid long stack traces | ||
pathCallback(err) | ||
}) | ||
}) | ||
} | ||
}, function (err) { | ||
|
@@ -274,7 +276,9 @@ Generator.prototype.compile = function (callback) { | |
this.compileDest = mktemp.createDirSync(this.dest + '/compile_dest-XXXXXX.tmp') | ||
async.eachSeries(self.compilers, function (compiler, callback) { | ||
compiler.run(self.preprocessDest, self.compileDest, function (err) { | ||
callback(err) | ||
process.nextTick(function () { // async to avoid long stack traces | ||
callback(err) | ||
}) | ||
}) | ||
}, function (err) { | ||
callback(err) | ||
|
3 comments
on commit 7b7fd51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw let me know if you want commit bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the offer, I am scared if I have commit bit, I will never sleep again :P
unsure but we use another trick, to only enforce 1 async turn in RSVP, it may be work checking out.
https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/async.js#L57-L65