Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Don't double-wrap callbacks. #11
When using Promises, a callback passed to .then() will sometimes pass through multiple .then() calls. If we aren't careful, we may end up wrapping a callback multiple times, resulting in a callback that creates a fiber which immediately creates another fiber and so on.
This is especially bad because in this chain situation of fibers-creating-fibers, none of the fibers complete before others are created, thus they force expansion of the fiber pool.
This, in turn, runs into a v8 bug in which each fiber created makes fiber-switching permanently slower, due to use of a linked list. See: meteor/meteor#7747
This change simply adds a field to the wrapped callbacks that marks them as not needing further wrapping.
I would appreciate if this could either rapidly find its way into a Meteor point release or if you could instruct me on how to force Meteor to use this patch in our build. This bug is causing repeated production outages, and although I have hotfixed it for now by editing the code in-place on the server, that's obviously not a sustainable solution.
This was referenced
Sep 5, 2016
added a commit
this pull request
Sep 9, 2016
@kentonv Not sure if you got a chance to try this last Friday, but the Meteor